### Random Post

### Recent Posts

- Enigma 427: Settle some new scores
- Puzzle 59: Cricket
- Enigma 426: Time and again
- Enigma 1084: 1-2-3 triangles
- Tantalizer 466: Diplomacy
- Tantalizer 467: Nine men went to mow
- Enigma 1085: Cut and run
- Enigma 425: Them thar’ Hills
- Puzzle 60: Uncle Bungle gets the last line wrong
- Enigma 1086: Stacking trays

### Recent Comments

Jim Randell on Enigma 427: Settle some new… | |

Jim Randell on Enigma 427: Settle some new… | |

geoffrounce on Enigma 1503: Division dec… | |

arthurvause on Enigma 425: Them thar’… | |

Jim Randell on Puzzle 59: Cricket |

### Archives

### Categories

- article (11)
- enigma (1,130)
- misc (2)
- project euler (2)
- puzzle (33)
- site news (43)
- tantalizer (34)
- teaser (3)

### Site Stats

- 170,314 hits

A straightforward program quickly finds the answer. This Python program runs in 34ms.

Solution:SNAP = 9376.Interestingly, the solution, if entered on a phone keypad, spells out the word ZERO.

For more details on

Trimorphic Numberssee Wikipedia or Wolfram Alpha.Indeed, as Arthur points out, the same approach as that to the recently published here (but originally set 33 years ago)

Enigma 49will yield the answer (and the answer is the same). Indeed this code can be run with command line arguments of “4” and “3” to find 4-digit numbers whose cube ends in the same 4 digits as the original number.This is the same code augmented to only consider numbers with distinct digits. It also runs in 34ms.

Another one for the diophantine solver (see Enigma 49)

For this one, x^3 = x mod 10000,

so x^3-x = x(x-1)(x+1) = 0 mod 2^4×5^4, then follow the argument in Enigma 49

P can have a value of one of 0 , 1 , 4 , 5 ,6 and 9 and looking at the cube number listing one can arrive at the solution with the highest value for SNAP

I further must add that 0 eliminates itself as SNAP must contain 4 different digits

On second thoughts, my diophantine solution is too simplistic – it should also cater for the situations where the factors of 2^4 are split between (x-1) and (x+1), and 5^4 could be in any of (x-1), x, (x+1). This makes the diophantine solution much messier, so here is an alternative, based on the simpler observation that 5^4 is a factor of only one of (x-1), x, (x+1)

I like this. A neat bit of analysis, leading to a neat bit of code. And you produce the candidates in numerical order anyway, so if you only wanted to find the largest candidate you could just reverse the direction of the search and finish when you found the first solution (which turns out to be the first value you try anyway, so it works just as well for a manual solution).

Here is a generalised solution using diophantine equations for N digits (without the constraint of all digits being different), tested for values of N from 3 to 100.

It turned out to be quite convoluted, so I have put an explanation on a blog entry

The square of SNAP must be a number of the form zxcv0001, where z,x,c,v can take any values (they could all be 0 if SNAP was not constrained to be made up of 4 different digits). Could this be programmed too?

For the value of SNAP that is the required solution, SNAP

^{n}ends in SNAP for integersn> 0. You can show this by induction.You can use the code I published to solve

Enigma 49to play around withN-digit numbers whereN^{P}ends inN.In the case of 1249, 3751, 6249, 8751 (and 0001, 4999, 5001, 9999 if we allow them: note the reflections about 5000), it’s true that SNAP² mod 10000 = 1. So then SNAP to any odd power, taken modulo 10000, equals SNAP. But here we have the case (the only one) where SNAP² mod 10000 = SNAP, and therefore so does SNAP³ and indeed SNAP to any power, as Jim points out.

I confess there was nothing remotely sophisticated (Diophantine, Eulerian, Gaussian, etc.) in my sledgehammer approach to find that out.