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<b<19 implies that, if a=1 or a=18, b=18 or b=2. And so on…which leads to a maximum of 20 questions, 10 for Abigail and 0 for Corentin. Here is my R implementation
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}