Archive for Le Monde

out of control…

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

Le Monde puzzle [#1159]

Posted in Books, Kids, R with tags , , , , , , on October 6, 2020 by xi'an

The weekly puzzle from Le Monde is quite similar to #1157:

Is it possible to break the ten first integers, 1,…,10, into two groups such that the sum over the first group is equal to the product over the second? Is it possible that the second group is of cardinal 4? of cardinal 3?

An exhaustive R search returns 3 solutions by

library(R.utils)
bitz<-function(i)
  c(rev(as.binary(i)),rep(0,10))[d<-1:10]
for (i in 1:2^10)
  if (sum(d[!!bitz(i)])==prod(b<-d[!bitz(i)])) print(b)
[1]  1  4 10 #40
[1] 6 7 #42
[1] 1 2 3 7 #42

which brings a positive reply to the question. Moving from N=10 to N=19 produces similar results

[1]  1  9 18 #162
[1]  2  6 14 #168
[1]  1  3  4 14 #168
[1]  1  2  7 12 #168

with this interesting pattern of only two acceptable products, but I am obviously unable to run the same code for N=49, which is the subsidiary question to the puzzle. Turning to a more conceptual (!) approach, over a long insomnia bout (!!) and a subsequent run, I realised that if there are three terms, x¹,x² and x³, in the second group, they need satisfy

x¹x²x³+x¹+x²+x³=½N(N+1)

and if in addition one of them is equal to 1, x¹ say, this equation simplifies into

(x²+1)(x³+1)=½N(N+1)

which always leads to a solution, as e.g. for N=49,

x¹=1, x²=24 and x³=48.

A brute-force search also led to a four term solution in that case

x¹=1, x²=7, x³=10 and x⁴=17.

abortion data, France vs. USA

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

As Le Monde pointed out at a recent report on 2019 abortions in France from Direction de la recherche, des études, de l’évaluation et des statistiques (Drees), showing an consistent rise in the number of abortions in France since 1995, with a rate of 15.6 abortions for 1000 women and the number around a third of the live births that year, I started wondering at the corresponding figures in the USA, given the much more restrictive conditions there. Judging from this on-line report by the Guttmacher Institute, the overall 2017 figures are not so different in both countries: while the abortion rate fell to 13.5‰, and the abortion/life birth ratio to 22%, the recent spike in abortion restrictions for most US States did not seem to impact considerably the rates, even though this is a nationwide average, hiding state disparities (like a 35% drop in Iowa or Alabama [and a 62% drop in Delaware, despite no change in the number of clinics or in the legislation]). In addition, France did not apparently made conditions more difficult recently (most abortions occur locally and the abortion rate is inversely correlated with income) and French (official) figures include off-clinic drug-induced abortions, while the Guttmacher institute census does not. The incoming (hasty) replacement of Judge Ruth Bader Ginsberg in the US Supreme Court may alas induce a dramatic turn in these figures if a clear anti-abortion majority emerges…

Le Monde puzzle [#1157]

Posted in Books, Kids, R with tags , , , , , , on October 1, 2020 by xi'an

The weekly puzzle from Le Monde is an empty (?) challenge:

Kimmernaq and Aputsiaq play a game where Kimmernaq picks ten different integers between 1 and 100, and Aputsiaq must find a partition of these integers into two groups with identical sums. Who is winning?

Indeed, if the sums are equal, then the sum of their sums is even, meaning the sum of the ten integers is even. Any choice of these integers such that the sum is odd is a sure win for Kimmernaq. End of the lame game (if I understood its wording correctly!). If some integers can be left out of the groups, then both solutions seem possible: calling the R code

P=1;M=1e3
while (P<M){
a=sample(1:M,10);P=Q=0
while((P<M)&(!Q)){
t=sample(1:7,1)     #size of subset
o=1         #total sum must be even
while(!!(s<-sum(o))%%2)o=sample(a,10-t)
Q=max(2*cumsum(b<-sample(o))==s)
P=P+1}}

I found no solution (i.e. exiting the outer while loop) for M not too large…  So Aputsiaq is apparently winning. Le Monde solution considers the 2¹⁰-1=1023 possible sums made out of 10 integers, which cannot exceed 955, hence some of these sums must be equal (and the same applies when removing the common terms from both sums!). When considering the second half of the question

What if Kimmernaq picks 6 distinct integers between 1 and 40, and Aputsiaq must find a partition of these integers into two groups with identical sums. Who is winning?

recycling the above R code produced subsets systematically hitting the upper bound M, for much larger values. So Kimmernaq should have a mean to pick 6 integers such that any subgroup cannot be broken into two parts with identical sums. One of the outcomes being

 
> a
[1] 36 38 30 18  1 22

one can check that all the possible sums differ:

aa=a
for(i in 2:5){
 bb=NULL
 while(length(bb)<choose(6,i))bb=unique(c(bb,sum(sample(a,i))))
 aa=c(aa,bb)}
unique(aa)

and the outcome is indeed of length 2⁶-2=62!

As an aside, a strange [to me at least] R “mistake” was that when recycling the variable F in a code-golfing spirit, since it is equal to zero by default, rather than defining a new Q:

while((P<M)&(!F)){
...
F=max(2*cumsum(b<-sample(o))==s)
P=P+1}

the counter P was not getting updated!

Le Monde puzzle [#1155]

Posted in Books, Kids, R with tags , , , , , , , on September 26, 2020 by xi'an

The weekly puzzle from Le Monde is another Sudoku challenge:

Anahera and Wiremu play a game for T rounds. They successively pick a digit between 1 and 3, never repeating the previous one, and sum these digits. The last to play wins if the sum is a multiple of 3. Who is the winner for an optimal strategy?

By a simple dynamic programming of the optimal strategy at each step

N=3
A=matrix(-1,20,N)
A[1,1:N]=1:N
for (T in 2:20)
for (i in 1:N) A[T,i]=i+ifelse(!T%%2, #parity check
max((i+A[T-1,-i])%%3), #avoid zero
min((i+A[T-1,-i])%%3)) #seek zero

the first to play can always win the game. Not fun!