Here you will find daily news and tutorials about R, contributed by over 573 bloggers.
There are many ways to follow us - By e-mail:On Facebook: If you are an R blogger yourself you are invited to add your own R content feed to this site (Non-English R bloggers should add themselves- here)

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=1
summits=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.)