## Le Monde puzzle [#1149]

Posted in Books, Kids, pictures, R with tags , , , , , , on July 1, 2020 by xi'an The weekly puzzle from Le Monde is a leaking variant on an old puzzle:

Three buckets have capacities of 8, 5 and 3 litres, respectively. At the start of the game, the 8 litre bucket is full and both others are empty. Aiming at reaching exactly 4 litres in one bucket, water is transferred between buckets. However, a fraction 1/k is lost with each transfer. If k=9, it is possible to reach 4 litres in three operations? If k=7, is it at all possible to reach 4 litres?

By sheer random search

```k=1/5
z=c(8,5,3)
m<-function(s){
i=sample(1:3,2)
s[i]=s[i]+ifelse(
rep((a<-z[i]-s[i])<(b<-s[i])*(1-k),2),
a*c(1,-1-k),b*c(1-k,-1))
s}```

I found that most fractions allow to reach 4 litres starting with k=2. (And am unsure the missing ones, like 18 or 21 are not due to a lack of luck… In particular, for k=9, the shortest path is

``` 8.000    0 0
2.375    5 0
0.000    5 2.11
0.000    4 3
```