[This article was first published on R – Xi'an's Og, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

The weekly puzzle from Le Monde is not much, again:

A number A is such that (1) the difference between two digits is never 1 (2) two digits are equal to 2 (3) it only involves 3 different digits (4) it is a multiple of 4 (5)  the sum of two of the digits is 5 (6) the product of the digits is not a multiple of 6 (7) the digits are between 0 and 6. What are the values of A with no digit equal to 0? What is the smallest A containing a zero?

as brute force produced 2052 as the smallest number with a zero. But I could not find numbers without a zero which seems indeed impossible since (1) plus (2) excludes 1 and 3, then (5) implies 0 and 5 are the other digits. Did I misunderstood the wording?!

Rereading the puzzle pointed out a detail I had missed:

A digit 1

Which of course reduces the number of constraints. Using the checking function (and possibly calling xor for the first time ever!)

rule<-function(A){
xor(!1%in%outer(A,A,'-'),!1%in%A)&
xor(sum(A==2)==2,!2%in%A)&
xor(length(unique(A))==3,!3%in%A)&
xor(!dig2num(A)%%4,!4%in%A)&
xor(5%in%outer(A,A,'+'),!5%in%A)&
xor(!!prod(A)%%6,!6%in%A)}


the first realisations of A are

  [1]   304   340   344  2452  2524  3004  3040  3044  3304  3340  3344
[12]  3400  3404  3440  3444  4252  4300  4304  4340  4344  5224 20452
[23] 20524 22335 22353 22355 22504 22533 22535 22540 22553 23235 23253
[34] 23255 23325 23523 23525 24052 24520 25024 25204 25233 25235 25240
[45] 25253 25323 25325 25420 25523 30004 30040 30044 30304 30340 30344
[56] 30400 30404 30440 30444 32235 32253 32255 32325 32523 32525 33004
[67] 33040 33044 33225 33304 33340 33400 33404 33440 33522 34000 34004
[78] 34040 34044 34300 34304 34340 34400 34404 34440 35223 35225 35322
[89] 35522 40252 40300 40304 40340 40344 42052 42520 43000 43004 43040
[100] 43044 43300 43304 43340 43400 43404 43440 44300 44304 44340 45220
[111] 50224 52024 52204 52233 52235 52240 52253 52323 52325 52420 52523
[122] 53223 53225 53322 53522 54220 55223 55322

with the first value containing 0 being 304. And no 6 ever appearing in the numbers!

To leave a comment for the author, please follow the link and comment on their blog: R – Xi'an's Og.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

# Never miss an update! Subscribe to R-bloggers to receive e-mails with the latest R posts.(You will not see this message again.)

Click here to close (This popup will not appear again)