**Xi'an's Og » R**, and kindly contributed to R-bloggers)

**T**he puzzle in ** Le Monde** this weekend is not that clear (for a change!), so I may be confused in the following exposition:

Three card players are betting with a certain (and different) number of chips each, between 4 and 9. After each game, the looser doubles the number of chips of the winner (while the second keeps her chips). The game stops if the looser cannot pay the winner. Find the initial configuration such that, at some point in the party, all players have the same number of chips.

So, if (x_{1},x_{2},x_{3}) is the chip configuration at time t for the ordered players, (2x_{1},x_{2},x_{3}-x_{1}) is the chip configuration at time (t+1). Rather than running an exhaustive search, given the limited number of possibilities, I decided to search at random, ending up with the R function

lemonde=function(chip,chap){ x=rep(-1,3) while (min(x)<0){ start=x=sample(chip:chap,3) while (length(unique(start))==1) start=x=sample(chip:chap,3) while ((min(x)>-1)&&(length(unique(x))>1)){ x=sample(x) #random winner x=c(2*x[1],x[2],x[3]-x[1]) }} list(start=sort(start),finish=x) }

leading to

> lemonde(4,9) $start [1] 7 8 9 $finish [1] 8 8 8

with a unique starting point. More interestingly, other configurations may have several starting points. Of course, a mathematical analysis of the problem would bring more light on the difference. Maybe the issue of ** Le Monde** next weekend (i.e., tonight!) will be enough.

> lemonde(4,10) $start [1] 5 9 10 $finish [1] 8 8 8 > lemonde(4,10) $start [1] 6 8 10 $finish [1] 8 8 8 > lemonde(4,10) $start [1] 7 8 9 $finish [1] 8 8 8

Filed under: R Tagged: fixed point, Le Monde, mathematical puzzle, R

**leave a comment**for the author, please follow the link and comment on his blog:

**Xi'an's Og » R**.

R-bloggers.com offers

**daily e-mail updates**about R news and tutorials on topics such as: visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...