**From New Scientist #2600, 21st April 2007**

I have made a number of cards, and have written on them all the nine-digit ninth powers, all the eight-digit eighth powers and so on down to the single-digit first powers. I have arranged these cards to form a ring so that each digit at the right-hand end of one card as seen from the inside of the ring matches that at the left-hand end of its neighbour, going clockwise.

What is the greatest number of digits I can have in the ring?

[enigma1439]

### Like this:

Like Loading...

When this puzzle was originally published I solved it in Perl using an exhaustive search, but it took about 30 minutes to run.

Here’s the search recoded in Python, with a couple of modifications to reduce the run time. It finds a number of maximal length solutions in 2.0s (running under PyPy).

It might be faster to assemble the numbers into chains, and then assemble non-intersecting chains into a ring.

Solution:The maximum number of digits in the ring is 64.