Random Post
Recent Posts
- BrainTwister #19: Angular arrangements
- Enigma 767: Safety in numbers
- BrainTwister #18: The arithmetical two-step
- Enigma 774: Sting in the tail
- BrainTwister #17: Semi-one numbers
- Enigma 773: Duodecimal
- BrainTwister #16: Order, order!
- Enigma 772: Have you seen the trailer?
- BrainTwister #15: Domino strips
- Enigma 771: Cross the island
Recent Comments
Archives
Categories
- article (11)
- braintwister (19)
- enigma (1,717)
- enigma-book-1982 (70)
- headscratchers-book-2023 (70)
- microteasers-book-1986 (11)
- misc (7)
- project euler (2)
- puzzle (90)
- puzzle# (249)
- site news (83)
- sphinx (4)
- tantalizer (254)
- tantalizer-book-1970 (40)
- teaser (7)
- today (1)
Site Stats
- 347,379 hits
We know that each square with the required property must be a 20-digit number (as each of the digits 0-9 occurs exactly twice), and so we can choose an appropriate lower bound on values to square to start our search.
The following Python program can also be used to explore numbers with the desired property in different bases.
Run: [ @replit ]
Solution: The smallest such number is 10012495377283485696.
In base b the number will be 2b digits long.
Here are the corresponding numbers for bases 2 – 16 (given in decimal and the appropriate base):
With a little adaptation we can also find a cube 10056421854778936239 and a biquadrate 23514473895962870016.
For base = 10 we can accelerate it a bit by only considering roots that are divisible by 3 (as the perfect square is divisible by 9 (sum digits = 90)).
Thanks to @jim randell, I start my search now later than my original sqrt(1e19).
This my one-liner using Counter.
And an -arguably more performant- implementation with a defaultdict. The moment a digit occurs three times, the scan will be aborted.
The fastest I can get is a search of squares of numbers that are multiples of 3. (A double pandigital is a multiple of 9, so its square root is a multiple of 3)
This is a little bit faster. Strange thing is that the an any() version of line 5-7 seems to be slower.