/* WRONG + WRONG = RIGHT (alphametic problem) in Picat. Alphametic problem: WRONG + WRONG = RIGHT There are 2 solutions is O is set to 0 (zero). If no such constraint the problem has 21 solutions. This program was created by Hakan Kjellerstrand, hakank@gmail.com See also my Picat page: http://www.hakank.org/picat/ */ import cp. main => go. go => LD = [W,R,O,N,G,I,H,T], LD :: 0..9, all_different(LD), (10000 * W + 1000 * R + 100 * O + 10 * N + G)*2 #= 10000 * R + 1000 * I + 100 * G + 10 * H + T, % O #= 0, solve(LD), println(LD), printf("%d%d%d%d%d+%d%d%d%d%d=%d%d%d%d%d\n",W,R,O,N,G,W,R,O,N,G,R,I,G,H,T), nl, fail, nl.