There is a thin line between fun and profit in cryptography. Letter puzzles demand cryptanalysis of substitution cyphers in the form of arithmetic and logical reasoning. Our test program can be phrased as follows: A poor college student was quite frugal and sent the following telegram to his parents. How much money did he want?
S E N D
+ M O R E
---------
M O N E Y
We have already introduced this problem in the language reference for the Jekejeke Runtime library. We use the same pure Prolog solution here. The pure Prolog solution is a brute force search over the 8! possibilities. The problem was again introduced in the language reference for the Jekejeke Minlog extension. We also use the same CLP(FD) solution here. The CLP(FD) solution is a straight forward formulation of the problem. Both approaches produce the same single solution:
9 5 6 7
+ 1 0 8 5
---------
1 0 6 5 2