Alphametic (or cryptarithm or word/verbal addition)
S E N D
+ M O R E
---------
M O N E Y
Each letter in the addition equation represents one of the digits zero through
9. Goal: determine the digit each letter represents, that makes the addition
correct. A letter that is used more than once (such as M above) represents the
same digit wherever it appears. Note: the leading letters (S and M above)
cannot represent zero.
This program: computes a sorted list of the puzzle's letters ("d e m n o r s y"
above), tests each permutation of 10 things (digits zero through 9) taken 8
(the number of unique letters in the puzzle above) at a time, puts the
permutation's digits "into" the puzzle's equation to see if the addition is
correct, outputs the answer found and the number of permutations tested (10! /
2! = 1814400). [For the equation to compute number of permutations, see
link.
For a discussion of solving this puzzle with a program, see
link.]
|