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

Following the presentation of the first Le Monde puzzle of the year, I tried a simulated annealing solution on an early morning in my hotel room. Here is the R code, which is unfortunately too rudimentary and too slow to be able to tackle n=1000.

#minimise sum_{i=1}^I x_i
#for 1le x_ile 2n+1, 1e ile I
#    Ige n, x_i ne x_j
#    a=x_i,b=x_j,i,jin I implies a+b=x_k for a kin I
n=6
m=2*n+1

complete=function(inde){

len=length(inde)
comp=outer(inde,inde,"+")
diag(comp)=inde
comp=sort(unique(comp[complen)&&(length(comp)n){

off=sample(ind,1,prob=ind)
newinde=sort(ind[ind!=off])
newinde=complete(newinde)

if (tempe*log(runif(1))
The solution to the puzzle (given in the next Le Monde issue) is to take only the even digits, resulting in a minimum sum equal to n(n+1).
Filed under: R, Statistics Tagged: Le Monde, mathematical puzzle, simulated annealing                var vglnk = {key: '949efb41171ac6ec1bf7f206d57e90b8'};
(function(d, t) {
var s = d.createElement(t);
s.type = 'text/javascript';
s.async = true;
// s.defer = true;
var r = d.getElementsByTagName(t);
r.parentNode.insertBefore(s, r);
}(document, 'script'));

Related
ShareTweet