# Le Monde puzzle [#810]

March 5, 2013
By

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

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.)

Filed under: Books, Kids, R Tagged: awalé, Le Monde, mathematical puzzle, oware, R, seeds

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.
{"found_math": false, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "url": "https://www.r-bloggers.com/le-monde-puzzle-810/", "fetch_time": 1582714680000000000, "content_mime_type": "text/html", "warc_filename": "crawl-data/CC-MAIN-2020-10/segments/1581875146341.16/warc/CC-MAIN-20200226084902-20200226114902-00524.warc.gz", "warc_record_offset": 845103566, "warc_record_length": 50116, "token_count": 682, "char_count": 2250, "score": 3.703125, "int_score": 4, "crawl": "CC-MAIN-2020-10", "snapshot_type": "latest", "language": "en", "language_score": 0.8806517124176025, "file_path": "/sailhome/yjruan/project/latent-lm/data/processed/finemath-4plus/finemath-4plus/train-00050-of-00064.parquet"}