In the example below the letters shall be replaced by numbers. The numbers are from 1
to 9
, and each letter has the same number (e.g. E = 4
all the time. Different letters must have different numbers, so E = W = 4
is not allowed):
If one choose e.g. E = 4
(and some other numbers for the other letters), it can be easily seen that
is not a correct solution because E is in the first two rows 4 but not in the third row!
After some attempts I found that
is a solution.
I know that there are also some other solutions which solve this problem correctly. So, my question is: How can I find with Mathematica (9.0.1) ALL possible solutions?
My approach is the following: I create an array with all possible combinations:
values =
Table[{(z*1000 + w*100 + e*10 + i), (v*1000 + i*100 + e*10 + r),
(z*1000 + w*100 + e*10 + i) + (v*1000 + i*100 + e*10 + r)},
{z, 1, 9}, {w, 1, 9}, {e, 1, 9}, {i, 1, 9}, {v, 1, 9}, {r,1, 9}];
And then I want to search in the array values
for the correct combinations. But I have some problems to write a nice searching-program for this. Could anybody help?
I also have doubts if it is a good idea to create such a big values
-array because I create numbers like 1111
which are forbidden. Is there a way that I can create a leaner array?
Or does anybody have another nice idea how I could find all correct solutions for this problem?
I would be very happy about any help!