## Archive for because it’s Friday

## compression artifacts

Posted in Books, Kids, Travel with tags because it's Friday, comics, solar system, space, space exploration, video compresion, Voyager, xkcd on January 22, 2021 by xi'an## how many Friday 13th?

Posted in Books, Kids, R with tags because it's Friday, calendar, R, superstition on December 18, 2020 by xi'an**A** short Riddler’s riddle on the maximum number of Fridays 13th over a calendar year, of which I found 9 by a dumb exploration :

bi=c(1:31,1:29,1:31,1:30,1:31,1:30,1:31,1:31,1:30,1:31,1:30,1:31)

oy=bi[-60]

for(j in 0:(length(cy<-c(bi,oy,oy,oy))-1)){#any day in quartade

dy=c(cy[(j+1):length(cy)],cy[1:j])

for(i in 0:6){

dz=(i+(1:length(cy)))%%7

if((k<-sum((dz==5)*(cy==13)))>9)print(c(i,j,k))}}

with no change whatsoever when starting another day of the year, including a Friday 13.(since this only gains 13 days!). An example of a quartade (!) with nine such days is the sequence 2012-2015 with 3+2+1+3 occurences….

## numbers of numbers with numbers of their numbers

Posted in Statistics with tags because it's Friday, combinatorics, riddle, The Riddler on April 6, 2019 by xi'an**A** funny riddle from The Riddler where the number of numbers that indicate the numbers of their numbers is requested. By which one means numbers like 22 (two 2’s) and 21322314 (two 1’s, three 2’s, two 3’s and one 4), the convention being that “numbers consist of alternating tallies and numerals”. And that numerals are “tallied in increasing order”. A reasoning based on the number of 1’s, from zero (where 22 seems to be the only possibility) to six (where 613223141516171819 is the only case) leads to a total of 59 cases (unless zero counts as an extra case) and a brute force R exploration returns the same figure:

for (t in 1:1e5){ az=sample((0:6),9,rep=TRUE) count=rep(TRUE,9) for (i in 1:9) count[i]=(sum(az==i)+(az[i]>0))==az[i] nit=0 while ((min(count)==0)&(nit<1e2)){ j=sample((1:9)[!count],1) az[j]=(sum(az==j)+(az[j]>0)) nit=nit+1} if (min(count)==1) solz=unique.matrix(rbind(solz,az),mar=1)}

The solution published on The Riddler differs because it also includes numbers with zeros. Which I find annoying to the extreme because if zeroes are allowed then every digit not in the original solution should appear as multiplied by 0, which is self-contradictory… For instance 22 should be 012203…09, except then there is one 1, one 3, and so on.

## the riddle of the stands

Posted in Books, Kids, R with tags because it's Friday, mathematical puzzle, R, The Riddler, urinals, xkcd on May 11, 2018 by xi'an**T**he simple riddle of last week on The Riddler, about the minimum number of urinals needed for n men to pee if the occupation rule is to stay as far as possible from anyone there and never to stand next to another man, is quickly solved by an R code:

ocupee=function(M){ ok=rep(0,M) ok[1]=ok[M]=1 ok[trunc((1+M/2))]=1 while (max(diff((1:M)[ok!=0])>2)){ i=order(-diff((1:M)[ok!=0]))[1] ok[(1:M)[ok!=0][i]+trunc((diff((1:M)[ok!=0])[i]/2))]=1 } return(sum(ok>0)) }

with maximal occupation illustrated by the graph below:

Meaning that the efficiency of the positioning scheme is not optimal when following the sequential positioning, requiring urinals. Rather than one out of two, requiring 2N-1 urinals. What is most funny in this simple exercise is the connection exposed in the Riddler with an Xkcd blag written a few years go about the topic.