**A** two-person game as Le weekly Monde current mathematical puzzle:

*Two players Amaruq and Atiqtalik are in a game with n tokens where Amaruq chooses a number 1<A<10 and then Atiqtalik chooses a different 1<B<10, and then each in her turn takes either 1, A or B tokens out of the pile.The player taking the last token wins. If n=150, who between Amaruq and Atiqtalik win if both are acting in an optimal manner? Same question for n=210.*

The run of a brute force R code like

B=rep(-1,200);B[1:9]=1
for (i in 10:200){
v=matrix(-2,9,9)
for (b in 2:9){
for (a in (2:9)[-b+1])
for (d in c(1,a,b)){
e=i-d-c(1,a,b)
if (max(!e)){v[a,b]=max(-1,v[a,b])}else{
if (max(e)>0) v[a,b]=max(v[a,b],min(B[e[which(e>0)]]))}}
B[i]=max(B[i],min(v[v[,b]>-2,b]))}

always produces 1’s in B, which means the first player wins no matter… I thus found out (from the published solution) that my interpretation of the game rules were wrong. The values A and B are fixed once for all and each player only has the choice between withdrawing 1, A, and B on her turn. With the following code showing that Amaruq looses both times.

B=rep(1,210)
for(b in(2:9))
for(a in(2:9)[-b+1])
for(i in(2:210)){
be=-2
for(d in c(1,a,b)){
if (d==i){best=1}else{
e=i-d-c(1,a,b)
if (max(!e)){be=max(-1,be)}else{
if (max(e)>0)be=max(be,min(B[e[which(e>0)]]))}}}
B[i]=be}

### Like this:

Like Loading...