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

**A**s a coincidence, while I was waiting for the solution to puzzle #737 published this Friday in ** Le Monde**, the delivery (wo)man forgot to include the weekend magazine and I had to buy it this morning with my baguette

*(as if anyone cares!)*. The solution is

*(y*and…it does not work! The value of

_{0},z_{0},w_{0})=(38,40,46)*(x*is indeed

_{1},y_{1},z_{1},w_{1})*(19,39,43,8.5)*. Now, it does not work because t

*he update mechanism used by the writers of the*, rather than one at a time: the update thus reads as

**column is to move all positions simultaneously***Le Monde*if

ufor^{n}=(x_{n},y_{n},z_{n},w_{n}),i=1,…,4,

if

u_{i}^{n-1}is not the maximum ofuand^{n-1}otherwise.

(to compare with my earlier proposal). In this new configuration, the core of the R code I use is

while (nodd){ nsuite=suite=start=c(0,sort(2*sample(1:23,3))) for (t in 1:20){ #some values of start never produce non-integer values #of suite and never visit suite[1]=0 nsuite[-4]=(suite[-4]+suite[-1]+48*(suite[-1]-suite[-4]<0))/2 nsuite[4]=(suite[4]+suite[1]+48*(suite[1]-suite[4]<0))/2 suite=nsuite%%48 if ((suite[1]==0)||(max(is.decimal(suite))==1)){ nodd=(max(is.decimal(suite))==1) print(t) break()} }}

**T**his new version leads to solutions (unsurprisingly!), returning

> print(start) [1] 0 12 24 36

as one solution in 8 steps and

> print(start) [1] 0 38 40 46

as the quickest solution in 6 steps.

Filed under: R Tagged: Le Monde, mathematical puzzle

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