From New Scientist #2405, 26th July 2003 [link]
I have placed six different non-zero digits evenly-spaced around the circumference of a circle of radius 10 centimetres. I can now write down all sorts of lists of digits by the following process:
Start at one of the digits, write it down, move to a digit exactly 10cm or 20cm away, write it down, move to a digit exactly 10cm or 20cm away, write it down, etc etc. (You are allowed to revisit digits in this way).
I have just produced a list of six digits in this way. The six-figure number which is formed by this list turns out to be a perfect fourth power. I have then started again and produced a list of four digits. The four-figure number which is formed by this list turns out to be a perfect cube.
What is that cube?
[enigma1249]
This one was a little bit more involved than I initially expected.
This Python 3 program runs in 52ms.
Solution: The cube is 2197 (= 13³).
There are 6 essentially different rings (along with their mirror images).
The 4th power is always 279841 (= 23⁴) which has no repeated digits, so fully populates the ring.
Some MMa code.
Quite a bit slower. Also we get two possible cubes, however we can see that 1728 wouldn’t be possible as it violates the move criteria.
Paul.
Yes, quite involved.
When I first read the puzzle, I didn’t twig that “starting again” meant starting from the same position, so I retrospectively added the check that the cube and fourth start with the same digit. The logic can actually be simplified to:
I’m not sure that “starting again” does necessarily mean that you have to start from the same position. My program doesn’t assume that, and it finds there is only one possible solution (although in that solution the fourth power and the cube do start with the same digit).
I do like the idea of considering the parity of the index of each digit within the numbers. As these must alternate in numbers we generate from the ring, this gives us a quick way to solve the problem manually. We can immediately discard any number which has repeated digits that occur at a different index parity (so any number with consecutive repeated digits is out, but so is any number with repeated digits where a digit appears at both an odd and an even index).
Of the 8 possible 6-digit fourth powers that consist of non-zero digits, only one of them survives this test: 279841.
This fully populates the ring so any 4-digit cube can only contain these digits. There are only two candidates: 1728 and 2197.
But looking at the index parities of the digits in the 4-digit cubes in the 6-digit fourth power we get: 1728 = (1, 1, 0, 1), 2197 = (0, 1, 0, 1). But these must alternate in any number generated from the ring, and as you can reach any of the odd parity digits from any of the even parity digits it follows that if we construct the ring for 279841 in any of the 12 possible ways it will always be possible to generate 2197 from the ring.
After reading the question again, I can see why my first solution produced 2 solutions – I allowed a fourth power containing zero to be considered. So version 3 is similart to version 1:
If you allow 0 in the ring you can find a second solution. The fourth power is 707281 (=29⁴), and we can make 1728 (=12³) from the same ring.
As the 707281 has a repeated digit the ring is not fully populated, but 1728 is made up of digits included only in the fourth power, so it doesn’t matter what digit is in the unused position in the ring (as it does not appear in either of the numbers).
Here’s a Python program that uses the idea of index parities to solve the problem.
I enjoyed this puzzle. A good programming practise I guess.