# Le Monde puzzle [#869]

April 26, 2014
By

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

A Le Monde mathematical puzzle once again in a Sudoku mode:

In an nxn table, all integers between 1 and n appear n times. If max denotes the maximum over the numbers of different integers on all rows and columns,  what is the minimum value of max when n=7? when n=11?

I tried to solve it by the following R code (in a pre-breakfast mode in my Reykjavik Airbnb flat!):

```#pseudoku
n=7
T=10^4
vals=rep(1:n,n)
minmax=n
for (t in 1:T){
psudo=matrix(sample(vals),ncol=n)
maxc=maxr=max(sapply(apply(psudo,1,unique),length))
if (maxc
but later realised that (a) the
sapply(apply(psudo,1,unique),length)
failed when all rows or all columns had the same number of unique terms and (b) I did not have to run the whole matrix:
vals=rep(1:n,n)
minmax=n
for (t in 1:T){
psudo=matrix(sample(vals),ncol=n)
maxc=max(length(unique(psudo[1,])),length(unique(psudo[,1])))
i=1
while((i
gaining a factor of 3 in the R execution. With this random exploration, the minimum value returned was 2,2,2,3,4,5,5,6,7,8 for n=2,3,4,5,6,7,8,9,10,11. Half-hearted simulating annealing during one of the sessions of AISTATS 2014 did not show any difference…
Filed under: Books, Kids, R, Statistics, University life Tagged: AISTATS 2014, Le Monde, mathematical puzzle, R, Reykjavik, sapply(), sudoku, unique()

var vglnk = { key: '949efb41171ac6ec1bf7f206d57e90b8' };

(function(d, t) {
var s = d.createElement(t); s.type = 'text/javascript'; s.async = true;
var r = d.getElementsByTagName(t)[0]; r.parentNode.insertBefore(s, r);
}(document, 'script'));

Related
ShareTweet

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.

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