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

A simple Le Monde mathematical puzzle after two geometric ones I did not consider:

1. Bob gets a 2×3 card with three integer entries on the first row and two integer entries on the second row such that (i) entry (1,1) is 1, (ii) summing up subsets of adjacent entries produces all integers from 1 to 21. (Adjacent means sharing an index.) Deduce Bob’s voucher.
2.  Alice gets Bob’s voucher completed into a 2×4 card with further integer entries. What is the largest value of N such that all integers from 1 to N are available through summing up all subsets of entries?

The first question only requires a few attempts but it can be solves by brute force simulation. Here is a R code that leads to the solution:

alsumz<-function(sol){return(
c(sol,sum(sol[1:2]),sum(sol[2:3]),sum(sol[4:5]),
sum(sol[c(1,4)]), sum(sol[c(1,5)]),sum(sol[1:3]),
sum(sol[c(1,4,5)]),sum(sol[c(1,2,5)]),
sum(sol[c(2,4,5)]), sum(sol[c(1,2,3,5)]),sum(sol[2:5]),
sum(sol[c(1,2,4)]),sum(sol[c(1,2,4,5)]),sum(sol[1:4]),
sum(sol)),sum(sol[c(2,3,5)]))}


produces (1,8,7,3,2) as the only case for which

(length(unique(alsum(sol)))==21)


The second puzzle means considering all sums and checking there exists a solution for all subsets. There is no constraint in this second question, hence on principle this could produce N=2⁸-1=255, but I have been unable to exceed 175 through brute force simulation. (Which entitled me to use the as.logical(intToBits(i) R command!)

Filed under: Books, Kids, R Tagged: Alice and Bob, Le Monde, mathematical puzzle, partition, R