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

*Related*

*Related*

**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 on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more…