# Le Monde puzzle [#827]

**Xi'an's Og » R**, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)

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

**B**ack to R (!) for the current *Le Monde* puzzle:

Given an unknown permutation of the set {1,…,6}, written on the faces of a cube, there exist a sequence of summits such that increasing by one unit the three numbers of the faces sharing the successive summits in the sequence leads to identical values over all faces. What was the initial permutation? What is the minimal number of steps to reach equality?

**M**y initial worry was to rewrite the summit constraint(s) in a manageable way. I tried with a 6×8 matrix, calling 1 the bottom face and 6 the top face (which are thus the only two that cannot get changed at the same time):

summits=matrix(0,6,8) for (i in 2:5){ summits[c language="(1,i,(i+1)%%6+2*(i==5)),(i-1)"][/c]=1 summits[c language="(6,i,(i+1)%%6+2*(i==5)),4+(i-1)"][/c]=1}

First, I sought a random exploration of the faces. However, I did impose the smallest and largest values on the top and bottom faces as they are the ones getting most and least updated compared with the other faces (?):

solve=rep(0,10^3) initia=matrix(0,6,10^3) for (alea in 1:10^3){ faces=initia[,alea]=c(1,sample(2:5),6) for (T in 1:100){ sumi=sample(1:8,1) faces=faces+summits[,sumi] if (diff(range(faces))==0) break() } if (diff(range(faces))==0){ solve[alea]=T} }

**T**he outcome is unsurprising in that the smallest number of summits is then 5, making all faces equal to 6. For a starting value equal to, e.g., {1,2,3,5,4,6}. *(Something that tooks a [wee] while for me to understand was why removing the sample(2:5) in the above makes a difference.)*

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

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

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

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.