# Enigmatic Code

Programming Enigma Puzzles

## Enigma 1577: Happy New Year

From New Scientist #2742, 9th January 2010 [link]

I have written down three 3-digit numbers which between them use nine different digits. One of the numbers is a perfect square and another is a triangular number. The sum of the three numbers is 2010.

What, in ascending order, are the three numbers?

[enigma1577]

### One response to “Enigma 1577: Happy New Year”

1. Jim Randell 9 February 2012 at 11:14 am

The following Python program runs in 38ms.

```from enigma import irange, printf

# 3-digit square numbers
for i in irange(11, 31):
n = i * i
d1 = set(str(n))
if not len(d1) == 3: continue

# 3-digit triangular numbers
for j in irange(14, 44):
t = j * (j+1) // 2
d2 = d1.union(set(str(t)))
if not len(d2) == 6: continue

# remaining number
r = 2010 - (n + t)
if not(99 < r < 1000): continue
d3 = d2.union(set(str(r)))
if not len(d3) == 9: continue
printf("{i}^2 = {n}, T[{j}] = {t}, r = {r}")
```

Solution: The numbers are: 325, 784 and 901.