[This article was first published on

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

**R – Xi'an's Og**, 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.

**A “**he said-she said” Le Monde mathematical puzzle (again in the spirit of the famous Singapore high-school birthdate problem):

Abigail and Corentin are both given a positive integer, a and b, such that a+b is either 19 or 20. They are asked one after the other and repeatedly if they are sure of the other’s number. What is the maximum number of times they are questioned?

If Abigail is given a 19, b=1 necessarily. Hence if Abigail does not reply, a<19. This implies that, if Corentin is given b=1 or b=19, he can reply a+b=19 or a+b=20, necessarily. Else, 1**
**

az=bz=cbind(20-(1:19),19-(1:19)) qwz=0;at=TRUE;bt=FALSE while ((max(az)>0)&(max(bz)>0)){ if (at){ for (i in 1:19){ if (sum(az[i,]>0)==2){ for (j in az[i,az[i,]>0]){ if (sum(bz[j,]==0)==2) az[i,]=rep(0,2)}} if (sum(az[i,]>0)<2){ az[i,]=rep(0,2)}}} if (bt){ for (i in 1:19){ if (sum(bz[i,bz[i,]>0]>0)==2){ for (j in bz[i,bz[i,]>0]){ if (sum(az[j,]==0)==2) bz[i,]=rep(0,2)}} if (sum(bz[i,]>0)<2){ bz[i,]=rep(0,2)}}} bt=!bt;at=!at;qwz=qwz+1}

To

**leave a comment**for the author, please follow the link and comment on their blog:**R – Xi'an's Og**.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.