Here you will find daily news and tutorials about R, contributed by over 750 bloggers.
There are many ways to follow us - By e-mail:On Facebook: If you are an R blogger yourself you are invited to add your own R content feed to this site (Non-English R bloggers should add themselves- here)

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 y_{1},…,y_{25}, and the first guess is x_{1},…,x_{25}, all taking values in {0,1}, the value of

is known. Changing only x_{25} into (1-x_{25}) leads to the knowledge of the corresponding y_{25}. If we keep changing each x_{i} one at a time and downwards, in at most 24 steps, we know y_{25},…,y_{2}, thus (y_{1}-x_{1})², hence y_{1}. 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.

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

whose output is

> rangep[1]

1

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