Archive for FiveThirtyEight

Tribonacci sequence

Posted in Books, Kids, R with tags , , , , , on January 3, 2023 by xi'an

A simplistic puzzle from The Riddler when applying brute force:

A Tribonacci sequence is based on three entry integers a ≤ b ≤ c, and subsequent terms are the sum of the previous three. Among Tribonacci sequences containing 2023, which one achieves the smallest fourth term, a+b+c ?

The R code

for(a in 1:m)
  for(b in a:m)
    for(e in b:m)

leads to (1,1,6) as the solution… Incidentally, this short exercise led me to finally look for a fix to entering vectors as arguments of functions requesting lists:"tri",as.list(sol[2023,]))

another drawer of socks

Posted in Books, Kids, R, Statistics with tags , , , , , , on November 6, 2022 by xi'an

A socks riddle from the Riddler but with no clear ABC connection! Twenty-eight socks from fourteen pairs of socks are taken from a drawer, one by one, and laid on a surface that only fit nine socks at a time, with complete pairs removed. What is the probability that all pairs are stored without running out of space? No orphan socks then!!

Writing an R code for this experiment is straightforward

for(v in 1:1e6){
 for(t in 2:18){

and it returns a value quite close to 0.7 for the probability of success. I was expecting a less brute-force resolution but the the Riddler only provided the answer of 70.049 based on the above tree of probabilities (which I was too lazy to code).

birthday paradox, one by one

Posted in Books, Kids, pictures, Statistics with tags , , , , , on November 1, 2022 by xi'an

An easy riddle, riding the birthday paradox. Namely how many people on average have to sequentially enter a room for a double birthday to occur?

The answer is straightforward,


as only the last person in can share a birthday with those already in. This sum equals 24.62. Since the “magic number” is 23, this may sound wrong but the median attached to the above distribution is truly 23. My R code is

for(n in 3:a)q[n]=q[n-1]*(1+1/(n-2)-(n-1)/365)

optimal Gaussian zorbing

Posted in Books, Kids, R, Statistics with tags , , , , , , on August 30, 2022 by xi'an

A zorbing puzzle from the Riddler: cover the plane with four non-intersecting disks of radius one towards getting the highest probability (under the standard bivariate Normal distribution).

As I could not see a simple connection between the disks and the standard Normal, beyond the probability of a disk being given by a non-central chi-square cdf (with two degrees of freedom), I (once again) tried a random search by simulated annealing, which ended up with a configuration like the above, never above 0.777 using a pedestrian R code like

for(t in 1:1e6){# move the disk centres
 #coverage probability
 #simulated annealing step
   if (sol$val<p) sol=list(val=pp,pos=rbind(A,B,C,D))}

I also tried a simpler configuration where all disk centres were equidistant from a reference centre, but this led to a lower “optimal” probability. I was looking forward the discussion of the puzzle, to discover if anything less brute-force was possible! But there was no deeper argument there beyond the elimination of other “natural” configurations (and missing the non-central χ² connection!). Among these options, having two disks tangent at (0,0) were optimal. But the illustration was much nicer:

a genuine riddle

Posted in Books, Kids, pictures with tags , , , , , on August 5, 2022 by xi'an

A riddle from The Riddler that was pure (if straightforward) logic rather than brute force compulation or mathematical modelling:

Four bags of many marbles are labelled R(ed), B(lue), G(green) and μ (mixed), except that all labels are wrong. Given the possibility to draw two balls, one at a time, from any bag, is it possible to select two monochromatic bags?

Bag μ draw is returning a color, R say, as it is a monochromatic bag. Drawing from another color bag, B say, will produce R or B, in which case it is μ, i.e., mixed (polychromatic), which means the other bags are monochromatic, or G. For this last case, bag B is either polychromatic, in which case bag G is made of blue marbles and bag R of green marbles, or monochromatic, in which case bag G is mixed and bag R is full of blue marbles, but monochromatic for either situation, hence to be chosen on top of bag μ.

%d bloggers like this: