Archive for 2020

on the edge of starvation

Posted in Kids, pictures, Travel with tags , , , , , , , , on October 18, 2020 by xi'an

meals that make a difference

Posted in Kids, pictures, Travel with tags , , , , , , , on October 11, 2020 by xi'an

classy New Yorker cover

Posted in Statistics with tags , , , , , , , on October 5, 2020 by xi'an

Le Monde puzzle [#1146]

Posted in Books, Kids, R with tags , , , , , , , , on June 5, 2020 by xi'an

The weekly puzzle from Le Monde is once more disappointing.

Everyday of the month, take 0, 1 or 2 units. If one unit taken past day, next day none can be taken. If two units taken two day ago, none can be taken the current day. What is the strategy maximising the number of units  for February? March? April? Generalise to 0,..,3 units taken each day with 0 compulsory three days after taking 3 units.

as taking 2-1-0 (or 3-2-1-0) sounds like the optimal strategy. Except at the final step when 2, 2-2, 2-2-0, and 1-0-2-2 are best. But then why would one distinguish between the three months..?! Because the outcome differ, as 30, 32, and 33, resp. (or 45, 48 and 51). With an average increase of 1 in the first case and 1.5 in the second.

Another puzzle took too much of my time, namely a code golf challenge to devise a code taking as input a matrix of moves over an n x x grid and returning as input the number of nodes and transient tributaries for each loop (or irreducible set) of the moves. Which I solved by running Markov chains from each starting point long enough to reach stationarity. Entering the moves as


and returning the result via 390 bytes

for(i in d<-1:n)I=rbind(I,j(i*d/d,d))
for(t in b<-1:m)I=g(I)
for(t in b)K[b+m*p(I<-g(I))]=1
for(k in 1:l(!!s))s[k]=l(!a(!!sweep(K,2,u[k,],'-'),1,l))

which could be much shorter if only matrices could be indexed from 0 as in C.

Le Monde puzzle [#1144]

Posted in Books, Kids with tags , , , , , , on May 19, 2020 by xi'an

The weekly puzzle from Le Monde is again using 2020 but not R!

Two teams involve a prime total number m of participants, with each player getting between 0 and 100 points. The total score for both teams is 2020, with team B less than team A on average. A single transfer from A to B increases the average scores for both A and B by 1/2. What is the difference of the averages? The transfer(ed) player, Camélia, had 5 points less  than the average score for A. What was the score of Camélia?

but I could not find a brute force solution and ended up finding that 2×2020=2x2x5x101 is a multiple of m, which leaves only


as the possible number of players. Which almost immediately leads to a difference of m/2 between the average scores. And then almost as immediately to Camélia’s score being 60. If one really needed an R function


does return a=11 but this is 100% useless!