# Enigma 1712

Spoiler for New Scientist Enigma 1712:

Find the set of perfect squares that between them use each of the digits 0 to 9 exactly twice and whose sum is as small as possible. Your squares must all be different, and 0 may not be a leading digit.

What is the sum of your set of squares?

The squares up to 529 (the square of 23) contain more than two of every digit except 7, which doesn’t appear even once; the smallest 7-containing squares are 576, 676, 729, 784, 1764… Other “difficult” digits are 0 (occurring in 100, 400, 900, 1024, 1089, 1600…), 3 (in 36, 324, 361, 1369…) and 8 (in 81, 289, 484, 784, 841, 1089, 1681…). Since 7 looks like the toughest constraint let’s start with 576 and 729 (we can’t use 576 and 676, that’s three 6s already). To that we can add 100 for the two 0s and 36 and 324 for the two 3s. But then for the two 8s we need 81 and… something >1999. That doesn’t look good.

Since 8 creates the problem here, let’s start with 7 and 8. Use 576 and 729 for the 7s, 81 and 289 for the 8s. Then 100 for the 0s. For the 3s, 36 and… no, 324, 361, and 1369 don’t work, and anything larger will make too large a sum. 484 instead of 289 still doesn’t allow 324, 361, or 1369. Nor does 676 instead of 576.

So it seems for our 7s and 8s we can’t find anything better than 81, 576, and 784. Then add 100, 36, and 324. For our first 9 we can use 9. That leaves us needing one each of 2, 5, and 9. We can’t use 9 and 25 since we’ve already used 9, but we can use 529 (the aforementioned square of 23). That gives us: 9+36+81+100+324+529+576+784=2439.

Is that a proof? I’m not sure there are no holes in it. But I’m fairly confident this is the smallest possible sum.