Le Monde puzzle [#1154]
This article is originally published at https://xianblog.wordpress.com
The weekly puzzle from Le Monde is another Sudoku challenge:
An n by n grid contains all numbers from 1 till n². Is it possible for fill the grid so that every row and every column has an integer average, for n=5, 7 9?
By sheer random search
`?`=rowSums; `+`=sample o=function(n){ x=matrix(+(n^2),n) while(any(c(?x,?t(x))%%n))x=x/x*+x x}
I found solutions for n=3,4,5, quite easily,
[,1] [,2] [,3] [,4] [,5] [1,] 20 15 14 13 3 [2,] 21 4 25 6 9 [3,] 2 1 23 18 11 [4,] 17 12 22 24 5 [5,] 10 8 16 19 7
correction, for n=6 as well
[,1] [,2] [,3] [,4] [,5] [,6] [1,] 4 12 11 23 8 32 [2,] 17 15 14 33 5 30 [3,] 35 28 27 7 13 22 [4,] 31 1 6 2 21 29 [5,] 25 36 20 34 16 19 [6,] 26 10 24 3 9 18
but larger values of n require a less frontal attack… Simulated annealing maybe.
Thanks for visiting r-craft.org
This article is originally published at https://xianblog.wordpress.com
Please visit source website for post related comments.