**Xi'an's Og » R**, and kindly contributed to R-bloggers)

**A** Le Monde mathematical puzzle of moderate difficulty:

How many binary quintuplets (a,b,c,d,e) can be found such that anypair of quintuplets differs by at least two digits?

**I** solved it by the following R code that iteratively eliminates quintuplets that are not different enough from the first ones, for a random order of the 2⁵ quintuplets because the order matters in the resulting number (the intToBits trick was provided by an answer on StackExchange/stackoverflow):

sol=0 for (t in 1:10^5){ #random permutations votes=sapply(0:31,function(x){ as.integer(intToBits(x))})[1:5,sample(1:32)] V=32;inin=rep(TRUE,V);J=1 while (J<V){ for (i in (J+1):V) if (sum(abs(votes[,J]-votes[,i]))<2) inin[i]=FALSE votes=votes[,inin];V=dim(votes)[2];inin=rep(TRUE,V) J=J+1} if (sol<V){ sol=V; levote=votes} }

which returns solutions like

> sol [1] 16 > levote [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [1,] 0 0 0 0 1 1 1 1 0 1 0 [2,] 0 1 0 1 0 1 0 1 0 1 1 [3,] 0 1 1 0 1 0 1 1 1 0 0 [4,] 0 1 1 1 0 0 0 0 0 1 0 [5,] 0 0 0 0 0 0 1 0 0 0 0 [,12] [,13] [,14] [,15] [,16] [1,] 0 1 1 0 1 [2,] 0 1 1 0 1 [3,] 1 0 0 1 1 [4,] 0 0 1 1 0 [5,] 1 0 1 0 1

(brute-force) answering the question!

**I**n the same Science leaflet, Marco Zito had yet another tribune worth bloggin’ about (or against), under the title “Voyage au bout du bruit” (with no apologies to Céline!), where he blathers about (background) noise ["bruit"] versus signal without ever mentioning statistics. I will not repeat the earlier feat of translating the tribune, but he also includes an interesting trivia: in the old TV sets of my childhood, the “snow” seen in the absence of transmission signal is due in part to CMB!

Filed under: Books, Kids, R Tagged: intToBits(), Le Monde, mathematical puzzle, R, StackExchange, stackoverflow

**leave a comment**for the author, please follow the link and comment on his blog:

**Xi'an's Og » R**.

R-bloggers.com offers

**daily e-mail updates**about R news and tutorials on topics such as: visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...