# Enigmatic Code

Programming Enigma Puzzles

## Enigma 1440: Enigma entries

From New Scientist #2601, 28th April 2007

I asked Tom, Dick and Harry how many “Enigma” puzzles each had entered last year. None of them had submitted more than one entry to any puzzle! The number of entries that each had submitted was triangular (a triangular numbers fits the formula n(n+1)/2, like 1, 3, 6, 10, 15).

The number of incorrect entries that each had submitted was a perfect square — the same square for each of them. The number of correct entries that each had submitted was prime — a different prime for each of them. The total number of correct entries that they had between them submitted was a multiple of the total number of incorrect entries that they had between them submitted.

What was that total number of correct entries?

[enigma1440]

### One response to “Enigma 1440: Enigma entries”

1. Jim Randell 16 April 2013 at 8:39 am

This Python program runs in 45ms.

```from itertools import count, combinations
from enigma import irange, Primes, printf

# there were 51 Enigma puzzles in 2006

# triangular numbers less than 51
tris = []
for i in count(1):
t = i * (i + 1) // 2
if t > 51: break
tris.append(t)

# primes up to 51
primes = Primes(51)

# consider the square that is the number of incorrect entries
for i in irange(1, 7):
s = i * i
# find 3 different primes that added to the square make a triangle
for ps in combinations((p for p in primes if p + s in tris), 3):
# the total number of correct entries needs to be a multiple of 3s
t = sum(ps)
(n, r) = divmod(t, 3 * s)
if n > 1 and r == 0:
printf("sum={t} [=3x{s}x{n} primes={ps}]")
```

Solution: The total number of correct entries is 60.

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