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)

The weekly Le Monde puzzle is (again) a permutation problem that can be rephrased as follows:

Find

wheredenotes the set of permutations on {0,…,10} and is defined modulo 11 [to turn {0,…,10} into a torus]. Same question for

and for

This is rather straightforward to code if one adopts a brute-force approach::

perminmax=function(T=10^3){
mins=sums=rep(500,3)
permin=matrix(0:10,ncol=11,nrow=3,byrow=TRUE)
for (t in 1:T){
perms=sample(0:10)
adde=perms+perms
sums[1]=max(adde)
adde=adde+perms
sums[2]=max(adde)
adde=adde+perms+perms
sums[3]=max(adde)
for (j in 1:3)
if (sums[j]<mins[j]){
mins[j]=sums[j];permin[j,]=perms}
}
print(mins)
print(permin)
}

(where I imposed the first term to be zero because of the invariance by permutation), getting the solutions