Send + More Money
Send + More Money
This is a classic example of a so-called cryptarithmetic problem. These are mathematical puzzles in which the digits are replaced by letters of the alphabet or other symbols. The problems dealing with valid sums are called alphametic problems. In the problem under consideration we are asked to replace each letter by a different digit so that the above sum, that is
SEND +MORE MONEY
Is correct. Here the variables are S,E, N, M ,O, R,Y . Because S and M are the leading digits, the domain for each of the consist of the integer interval [1..9 ] . The domain of each of the remaining variables consist of the integer interval [1..9 ] . This problem can be formulated as the equality constraint
1000S + 100E + 10N + D 1000M + 100O + 10R + E = 10000M + 1000O + 100N + 10E + Y
mx-clojure
(fd/in s e n d m o r y (fd/interval 0 (fd/distinct [s e n d m o r y]) (fd/!= m 0) (fd/!= s 0) (fd/eq (= (+ (* 1000 s) (* 100 (* 1000 m) (* 100 (+ (* 10000 m) (* 1000 o) (* 100 (smm) 9))
e) (* 10 n) d o) (* 10 r) e) n) (* 10 e) y))))))