**Xi'an's Og » R**, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

**I** received at last my weekend edition of ** Le Monde** and hence the solution proposed by the authors (Cohen and Busser) to the puzzle #14. They obtain a strategy that only requires at most 19 steps. The idea is to start with a first test, which gives a reference score

*S*

*, and then work on groups of four questions, whose answers can be found in at most three steps. For instance, starting with*

_{0}*x*, the second test uses

_{1},…,x_{25}*(1-x*

_{1}),*(1-x*),

_{2}*x*,…,x

_{3}_{25}, and changes the score

*S*

*by -2,2 or 0. In the first two cases, this determines*

_{0 }*y*and it suffices to use

_{1},y_{2 }*x*

_{1},*x*

_{2},*(1-x*

_{3}),*(1-x*),

_{4}*x*…,x

_{5}_{25}, to find

*y*in one or two steps. If the score

_{3},y_{4 }*S*

*does not change, considering*

_{0 }*x*

_{1},*(1-x*),

_{2}*(1-x*

_{3}),*(1-x*),

_{4}*x*…,x

_{5}_{25}, and then maybe

*x*

_{1},*(1-x*x

_{2}),_{3},

*(1-x*),

_{4}*x*…,x

_{5}_{25}, produces again the value of

*y*. If one repeats the algorithm one group of four after another, there are six such groups and the maximal number of step is

_{1},…,y_{4}1+6*3=19

since the final answer *y _{25}* is known by deduction from

*S*

*. An additional improvement not mentioned in the journal is achieved in checking after any change whether or not the new score is equal to zero.*

_{0}*(In both my solution and theirs, there is an extra step to propose the correct solution, which means in my case an exact average of steps equal to 25, by the geometric argument.)*

**F**or the current solution, here is an R code that evaluates the distribution of the number of steps:

rangep=rep(0,25) for (t in 1:10^5){ s=2 for (j in 1:6){ y=sample(c(0,1),4,rep=T) x=z=rep(1,4) Delta0=sum(as.numeric(y!=x)) z[1:2]=0 Delta=sum(as.numeric(y!=z)) if (abs(Delta-Delta0)==2){ z=c(1,1,0,0) Delta=sum(as.numeric(y!=z)) s=s+2+(abs(Delta-Delta0)!=2) }else{ z=c(1,0,0,0) Delta=sum(as.numeric(y!=z)) s=s+2+(abs(Delta-Delta0)!=3) } } rangep[s]=rangep[s]+1 }

The fit by a binomial is rather poor, but this is not surprising given the two-stage decision. In any case, this does better than my earlier solution!

Filed under: Books, R, University life Tagged: Le Monde, mathematical puzzle

**leave a comment**for the author, please follow the link and comment on their blog:

**Xi'an's Og » R**.

R-bloggers.com offers

**daily e-mail updates**about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.