Le Monde puzzle [#810]

The current puzzle is as follows:

Take a board with seven holes and seeds. The game starts with one player putting the seeds on the holes as he or she wishes. The other player picks a seed wherever. Then, alternatively, each player picks a seed in a hole contiguous to the previous one. The loser is the one finding only empty holes to pick from. Who is the winner with 28? 29? 30 seeds?

This is a simplified version of the awalé or oware we used to play with my kids.

I first defined a recursive function on the win/loose value of a particular location, based on the assumption that each player was picking the best location at each step:

f=function(x,i){
 if (x[i]==0){# losing location
    v=0;return(v)}else{

   if ((i>1)&&(i<7)){
     x[i]=x[i]-1;return(1-max(f(x,i-1),f(x,i+1)))
     }else{

       if (i==1){ x[i]=x[i]-1;return(1-f(x,2))}
       if (i==7){ x[i]=x[i]-1;return(1-f(x,6))}
       }
}}

and then checked whether or not winning solutions were available for 28, 29, and 30 seeds dropped at random:

N=28 #number of seeds
glosol=1  #boolean
for (t in 1:10^3){#random starts

  seeds=sample(1:7,N,rep=TRUE)
  x=rep(0,7)
  for (i in 1:7) x[i]=sum(seeds==i)

  sol=i=0 #second player result
  while ((i<7)&&(sol==0)){
        i=i+1;sol=f(x,i)}
  if (sol==0){ #winning configuration for first player
    glosol=0;print(x);break()}
  }

getting solutions for 28 (5 6 2 3 5 5 2) and 30 (6 6 2 4 4 5 3), but none for 29.

Actually, the rule seems to be that odd numbers get no solutions and even numbers get solutions (e.g., 1 1 1 1 1 2 1 for 8 seeds). (This means further that to build a winning allocation for 2N seeds, we only need to take a configuration at random with 2N+1 seeds and check which seed we need to remove to get a winning (for the “other” player) configuration.)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 703 other followers