**From New Scientist #2279, 24th February 2001** [link]

In the following statement digits have been consistently replaced by capital letters, different letters being used for different digits:

VIER and NEUN are both perfect squares.

If I told you the number represented by VIER you could deduce with certainty the number represented by NEUN. Alternatively, if I told you the number represented by NEUN you could deduce with certainty the number represented by VIER.

What is the numerical value of the square root of (VIER × NEUN)?

[enigma1123]

### Like this:

Like Loading...

*Related*

We can generate the 4-digit squares and look for pairs that match the alphametics VIER and NEUN ourselves, or we can use the

SubstitutedExpression()solver from theenigma.pylibrary to get a shorter program (although it does take slightly longer to run).Once we have the pairs I use the

filter_unique()function to select the sets which give the solution.This Python program runs in 47ms.

Solution:The square root of (VIER × NEUN) is 7663.VIER = 6241 = 79², NEUN = 9409 = 97².

The use of the

unpack()function in lines 13-14 allows the code to work unmodified in both Python 2 or Python 3.As different letters are used for different digits, VIER and NEUN must share the letter ‘E’

I did a Python dictionary solution, with ‘E’ as the key and the tuple (VIER, NEUN ) as the value

and looked for a single value of (VIER, NEUN ) based on the key ‘E’

A full dictionary print-out of key (letter ‘E’) and values (VIER,NEUN] gives:

6 [(1369, 4624), (1369, 5625), (1764, 5625), (4761, 5625),

(7569, 1681), (7569, 4624)]

5 [(4356, 1521), (7056, 1521)]

4 [(6241, 9409)]