## Le Monde puzzle [#1139]

Posted in Books, Kids, R, Statistics with tags , , , , , on April 24, 2020 by xi'an A weekly Monde current mathematical puzzle that reminded me of an earlier one (but was too lazy to check):

The integer n=36 enjoys the property that all the differences between its ordered divisors are also divisors of 36. Find the only 18≤m≤100 that enjoys this property such that all its prime dividers areof multiplicity one. Are there other such m’s?

The run of a brute force R search return 42 as the solution (codegolf welcomed!)

```y=z=1:1e5
for(x in y)z[y==x]=!sum(x%%diff((1:x)[!x%%(1:x)]))
y=y[z==1]
for(k in generate_primes(2,max(y)))y=y[!!y%%k^2]
```

where generate_primes is a primes R function. Increasing the range of y’s to 10⁵ exhibits one further solution, 1806.

## Le Monde puzzle [#1133]

Posted in Books, Kids, R with tags , , , , , , on March 28, 2020 by xi'an A weekly Monde current mathematical puzzle that reminded me of an earlier one (but was too lazy to check):

If ADULE-ELUDA=POINT, was is the largest possible value of POINT? With the convention that all letters correspond to different digits and no digit can start with 0. Same question when ADULE+ELUDA=POINT.

The run of a brute force R search return 65934 as the solution (codegolf welcomed!)

```dify<-function(adule)
num2dig<-function(dif) (dif%/%10^(0:4))%%10
sl=NULL
for (t in 1:1e6){
sl=as.matrix(distinct(as.data.frame(sl),.keep_all = TRUE))
```

where distinct is a dplyr R function.

```> 94581-18549
 76032
```

The code can be easily turned into solving the second question

```> 31782+28713
 60495
```

## Le Monde puzzle [#1134]

Posted in Books, R with tags , , , , , , on March 24, 2020 by xi'an A Monde mathematical puzzle on gcd’s and scm’s:

If one replaces a pair (a,b) of integers with the pair (g,s) of their greatest common denominator and smallest common multiple, how long at most before the sequence ends. Same question when considering a collection of five integers where two are selected by the pair (g,s) of their greatest common denominator and smallest common multiple.

The first question is straightforward as s is a multiple of s. So the sequence ends at most after one run. For five, run of a brute force R search return 9 as “the” solution (even though the true maximum is 10, as illustrated by the quintuplet (16,24,36,54,81):

```ogcd <- function(x,y){r<-x%%y
return(ifelse(r,ogcd(y,r),y))}

oscm<-function(x,y) x*y/ogcd(x,y)

divemul<-function(a,b) return(c(oscm(a,b),ogcd(a,b)))

for (t in 1:1e5){
ini=sample(1:1e2,5)
i=0;per=ker=sample(ini,2)
nez=divemul(per,per)
while(!max(nez%in%per)){
ini=c(ini[!ini%in%per],nez)
per=sample(ini,2)
ker=rbind(ker,per)
nez=divemul(per,per)
i=i+1}
sol=max(sol,i)}
```

## Le Monde puzzle [#1132]

Posted in Kids, R, Statistics with tags , , , , , on February 24, 2020 by xi'an A vaguely arithmetic challenge as Le weekly Monde current mathematical puzzle:

Given two boxes containing x and 2N+1-x balls respectively. If one proceeds by repeatedly transferring half the balls from the even box to the odd box, what is the largest value of N for which the resulting sequence in one of the boxes covers all integers from 1 to 2N?

The run of a brute force R search return 2 as the solution

```lm<-function(N)
fils=rep(0,2*N)
bol=c(1,2*N)
while(max(fils)<2){
fils[bol]=fils[bol]+1
bol=bol+ifelse(rep(!bol%%2,2),-bol,bol)*c(1,-1)/2}
return(min(fils))}
```

with obvious arguments that once the sequence starts cycling all possible numbers have been visited:

```> lm(2)
 1
> lm(3)
 0
```

While I cannot guess the pattern, there seems to be much larger cases when lm(N) is equal to one, as for instance 173, 174, 173, 473, 774 (and plenty in-between).

## Le Monde puzzle [#1129]

Posted in Kids, R with tags , , , , , , on February 10, 2020 by xi'an A number challenge as Le weekly Monde current mathematical puzzle:

When the three consecutive numbers 110, 111 and 112, they all are multiples of the sum of their digits. Are there 4 consecutive numbers with three digits like this? A contrario, does there exist 17 consecutive numbers with three digits such that they cannot be divided by the sum of their digits? 18?

The run of a brute force R search return 510,511,512,513 as the solution to the first question

```library(gtools)
bez=!(100:999)%%apply(baseOf(100:999),1,sum)
> (100:897)[bez[-(1:3)]*bez[-c(1:2,900)]*bez[-c(1,899:900)]*bez[-(898:900)]==1]
 510
```

And to the second one:

```> max(diff((1:899)[!!diff(bez)]))
 17
```