Some time ago the following puzzle was posed in the newsgroup sci.math.symbolic.
Let E, F, H, N, O, R, T, U, and W be unique, positive, single-digit integers. They fulfill the following conditions:
ONE must be a square, and
In this puzzle the expression "THREE+1" is defined as the sum , the remaining constraints being defined in the same way.
Determine E, F, H, N, O, R, T, U, and W.
A brute force solution would be to check for all possible values of E, F, H, N, O, R, T, U, and W (each ranging independently from 0 to 9) to fulfill the conditions. This would mean to check nearly one billion cases. Although certainly doable on a 1999-vintage computer, it is not a solution that can be efficiently generalized to more variables. In the following, we will implement a solution that is not specifically tailored to this problem, but which can be used to solve any problem of this kind.
Let us first calculate all possible sets of conditions arising from the puzzle. Every row in the following table is one possibility for the four conditions to be fulfilled.
These are 48 possible combinations.
Here is an example of all nonnegative integer square numbers between 0 and 1234.
Given an expression of the form word + integer, the function
Here is an example.
Both realizations for the letters give a square.
Let us again look at an example. Here are the possible digit realizations for
The following 14-digit realizations are the compatible realizations.
Now we can take a set of conditions from
We get a nontrivial solution. Now let us check all other combinations of
No other solutions have been found. (The last evaluation effectively searched the entire solution space of the puzzle in less than a second, on a 1999-vintage computer.) Let us finish by substituting the calculated result into the original condition to check that the solution is OK.
Converted by Mathematica October 5, 1999 [Next Page]