Le Monde puzzle [#14]

[This article was first published on 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.

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

Hence, if the correct answers are y1,…,y25, and the first guess is x1,…,x25, all taking values in {0,1}, the value of

(y_1-x_1)^2+\cdots+(y_{25}-x_{25})^2

is known. Changing only x25 into (1-x25) leads to the knowledge of the corresponding y25. If we keep changing each xi one at a time and downwards, in at most 24 steps, we know y25,…,y2, thus (y1-x1, hence y1. This shows that there exists a strategy with 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 yi 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

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

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)