Enigma 1736

Spoiler for New Scientist Enigma 1736: “Child’s Play” (Follow the link to see the puzzle.)

There’s probably some smart way to do this with properties of modular arithmetic, Chinese Remainder theorem, something, but I’ve never really gotten that stuff to click. So we’ll do it like this.

First of all, the 0th digit (from the right, starting with 0; that is, the 100-th place) of (SNAP)3 is just the 0th digit of P3, so D(P,0) = P where D(n, m) is defined to be the mth digit of the decimal representation of n. (Is there an official name or notation for that? I don’t know of one.) The digits and their cubes are

 n n3 0 0 1 1 2 8 3 27 4 64 5 125 6 216 7 343 8 512 9 729

so P must be 0, 1, 4, 5, 6, or 9.

The 1st digit of (SNAP)3 is unaffected by S and N; it’s the same as the 1st digit of (10A+P)3 = 103A3+3(102A2P)+3(10AP2)+P3. The first two terms don’t affect the 1st digit, which is just 3AP2+D(P3,1) modulo 10, which must equal A. For instance, for P=9:

243A+2 modulo 10 = 3A+2 modulo 10 = A or 2A+2 modulo 10 = 0 => A = 4 or 9.

And indeed, 493 = 117649 and 993 = 970299. But A and P must be different, so if P is 9, A must be 4. Proceeding likewise with the other cases (equality is modulo 10):

P = 0: 3A(02)+0 = A => A = 0 (duplicates P)
P = 1: 3A(12)+0 = A => 2A = 0 => A = 0 or 5
P = 4: 3A(42)+6 = A => 7A+6 = 0 => A = 2
P = 5: 3A(52)+2 = A => 4A+2 = 0 => A = 2 or 7
P = 6: 3A(62)+1 = A => 7A+1 = 0 => A = 7

So “AP” is 01, 51, 24, 25, 75, 76, or 49.

Likewise the 2nd digit of (SNAP)3 is the 2nd digit of (100N+(AP))3 (careful, here (AP) means 10A+P, the 2-digit number) = 106N3 + 3(104N2(AP)) + 3(100N(AP)2) + (AP)3. So 3N(AP)2 + D((AP)3,2) modulo 10 = N. Squares (modulo 10, which is all we need) and cubes of our (AP) candidates are:

 n n2 (mod 10) n3 1 1 1 51 1 132651 24 6 13824 25 5 15625 75 5 421875 76 6 428976 49 1 117649

So:

AP = 01: 3N(1)+0 = N => 2N = 0 => N = 0 (duplicates A) or 5
AP = 51: 3N(1)+6 = N => 2N+6 = 0 => N = 2 or 7
AP = 24: 3N(6)+8 = N => 7N+8 = 0 => N = 6
AP = 25: 3N(5)+6 = N => 4N+6 = 0 => N = 1 or 6
AP = 75: 3N(5)+8 = N => 4N+8 = 0 => N = 3 or 8
AP = 76: 3N(6)+9 = N => 7N+9 = 0 => N = 3
AP = 49: 3N(1)+6 = N => 2N+6 = 0 => N = 2 or 7

“NAP” is 501, 251, 751, 624, 125, 625, 375, 875, 376, 249, or 749.

Finally we can get candidates for S the same way; 3S(NAP)2 + D((NAP)3,3) modulo 10 = S. Squares and cubes of our (NAP) candidates are:

 n n2 (mod 10) n3 501 1 125751501 251 1 15813251 751 1 423564751 624 6 242970624 125 5 1953125 625 5 244140625 375 5 52734375 875 5 669921875 376 6 53157376 249 1 15438249 749 1 420189749

NAP = 501: 3S(1)+1 = S => 2S+1 = 0 => no solution
NAP = 251: 3S(1)+3 = S => 2S+3 = 0 => no solution
NAP = 751: 3S(1)+4 = S => 2S+4 = 0 => S = 3 or 8
NAP = 624: 3S(6)+0 = S => 7S = 0 => S = 0
NAP = 125: 3S(5)+3 = S => 4S+3 = 0 => no solution
NAP = 625: 3S(5)+0 = S => 4S = 0 => S = 0 or 5 (duplicates P)
NAP = 375: 3S(5)+4 = S => 4S+4 = 0 => S = 4 or 9
NAP = 875: 3S(5)+1 = S => 4S+1 = 0 => no solution
NAP = 376: 3S(6)+7 = S => 7S+7 = 0 => S = 9
NAP = 249: 3S(1)+8 = S => 2S+8 = 0 => S = 1 or 6
NAP = 749: 3S(1)+9 = S => 2S+9 = 0 => no solution

So all possible values of “SNAP” are: 0624, 0625, 1249, 3751, 4375, 6249, 8751, 9375, and the largest, 9376 (whose cube is 824238309376).

(And having done that, I took approximately 1/20 as long to write a 5-line Perl script that got the same results.)

3 thoughts on “Enigma 1736”

1. That short Perl script just looped over values for SNAP from 0 (well, should have been 0123) to 9999 (should have been 9876) looking for ones that met the conditions, but obviously it doesn’t scale to generalizations with larger numbers of digits. But the process shown above can be scripted, and yields fun results like:

4162958075 = 12502883459986876923646836986985675416295807

In fact 4162958074 = 30033652152511055494841525000000001 so 4162958074n+1 ends in 416295807 for all n.

2. puerilescribble says:

There is a much quicker solution. Just notice that SNAP^3-SNAP=(SNAP-1)*SNAP*(SNAP+1) has to be divisible by 10^4 and therefore by 5^4 and therefore exactly one of SNAP-1, SNAP and SNAP+1 has to be divisible by 5^4. Then just check multiples of 5^4 (+-2) working backwards from 16*5^4=10000.

1. Thanks… yes, I was thinking of something like that after posting this, but didn’t quite follow it through to an alternate solution.