Le Monde puzzle [#827]

Back 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?

My 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(1,i,(i+1)%%6+2*(i==5)),(i-1)]=1
  summits[c(6,i,(i+1)%%6+2*(i==5)),4+(i-1)]=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}
}

The 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.) The solution in Le Monde spells out the solution more clearly as a cube whose opposite faces should sum up to 7…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 670 other followers