# Enigmatic Code

Programming Enigma Puzzles

## Enigma 1454: Fourth powers

From New Scientist #2615, 4th August 2007

Harry, Tom and I each replaced each asterisk with a digit in such a way that the six-digit number that could be read down, the five-digit number that could be read from left to right and the four-digit number that could be read at an angle of 45° to each of the other two were fourth powers. We did not mind whether the four-digit number was read from bottom left to top right or from top right to bottom left.

No two of our solutions were identical, but Harry and Tom’s solutions had two fourth powers in common.

Which three fourth powers did I use in my solution?

[enigma1454]

Advertisements

### One response to “Enigma 1454: Fourth powers”

1. Jim Randell 6 March 2013 at 9:32 am

This Python program runs in 35ms.

from itertools import count, product, combinations
from enigma import printf

# the powers are arrange such that the intersections are:
# AxxB, BxxCx, AxxCxx or BxxA, BxxCx, AxxCxx

# we need 4, 5 and 6 digit 4th powers
(p4s, p5s, p6s) = ([], [], [])
for i in count(6):
n = str(i ** 4)
if len(n) == 4: p4s.append(n)
elif len(n) == 5: p5s.append(n)
elif len(n) == 6: p6s.append(n)
else: break

# find 5 and 6 digit powers that share the digit at position 3
r = set()
for p5, p6 in product(p5s, p6s):
if p5[3] != p6[3]: continue
# and then we need a 4 digit power that begins with one initial
# digit and ends in the other
for p4 in p4s:
if not((p4[0] == p5[0] and p4[3] == p6[0]) or
(p4[0] == p6[0] and p4[3] == p5[0])): continue
t = tuple(int(x) for x in (p4, p5, p6))
r.add(t)
print(t)

# Harry & Tom's solutions have 2 powers in common
for (H, T) in combinations(r, 2):
if len(set(H).intersection(T)) != 2: continue
# Dick's is a different solution
for D in r.difference((H, T)):
printf("D = {D} [H/T = {H}/{T}]")

Solution: You used 2401 (= 74), 20736 (= 124) and 130321 (= 194) in your solution.

This site uses Akismet to reduce spam. Learn how your comment data is processed.