Here you will find daily news and tutorials about R, contributed by over 750 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)

However, reading the solution in the next edition of Le Monde, the authors claim there are solutions up to 50. I wonder why the crude search above fails so suddenly, between 12 and 13! So instead I tried a recursive program that exploits the fact that subchains are also verifying the same property:

findord=function(ens){
if (length(ens)==2){
sol=ens
foundsol=isprime(sum(ens))}
else{
but=sample(ens,1)
nut=findord(ens[ens!=but])
foundsol=FALSE
sol=ens
if (nut$find){
tut=nut$ord
foundsol=max(isprime(but+tut[1]),
isprime(but+tut[length(tut)]))
sol=c(tut,but)
if (isprime(but+tut[1]))
sol=c(but,tut)
}
}
list(find=foundsol,ord=sol)
}

And I ran the R code for N=13,14,…

> stop=TRUE
> while (stop){
+ a=findord(1:N)
+ stop=!(a$find)}

until I reached N=20 for which the R code would not return a solution. Maybe the next step would be to store solutions in N before moving to N+1. This is just getting me too far from a mere Saturday afternoon break.