# Le Monde puzzle [#14]

**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.

**L**ast week Le Monde puzzle *(I have not received this week issue yet!)* was about deriving an optimal strategy *in less than 25 steps* for finding the 25 answers to a binary multiple choice test, when at each trial, only the number of correct answers is known.

**H**ence, if the correct answers are *y _{1},…,y_{25}*, and the first guess is

*x*, all taking values in {0,1}, the value of

_{1},…,x_{25}is known. Changing only *x _{25}* into

*(1-x*leads to the knowledge of the corresponding

_{25})*y*. If we keep changing each

_{25}*x*one at a time and downwards, in

_{i}*at most*24 steps, we know

*y*, thus

_{25},…,y_{2}*(y*, hence

_{1}-x_{1})²*y*. This shows that there exists a strategy with

_{1}*25 steps or less*that provides the answer to the multiple choice test. If we are unlucky enough in our choice, can we reach the 25 steps? Here is a simulation experiment to explore this question, where the stopping rule is associated with all wrong or all right remaining answers.

</p> <p style="text-align: justify;">rangep=rep(0,25) for (t in 1:10^6){ y=sample(c(0,1),25,rep=T) x=sample(c(0,1),25,rep=T) p=25 Delta=sum((x[1:p]-y[1:p])^2) while ((Delta>0)&&(Delta<p)){ p=p-1} rangep[p]=rangep[p]+1 }

whose output is

</p> <p style="text-align: justify;">> rangep[1]</p> <p style="text-align: justify;">1</p> <p style="text-align: justify;">

so there was one occurrence where eliminating one *y _{i}* at a time, we need to do the 25 steps.

*(Note I am not saying this is the optimal strategy, just one that satisfies the constraint.)*

Filed under: R Tagged: Le Monde, mathematical puzzle, multiple answer test, R

**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.