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

The 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 (x1,x2,x3) is the chip configuration at time t for the ordered players, (2x1,x2,x3-x1) 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)
}
```

```> 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