/* Gardner's TWO+TWO=FOUR problem in Picat. Via OscaR's GardnerTwoPlusTwo program: """ Martin Gardner Problem: In this addition problem, each letter stands for a different digit. T W O + T W O -------- F O U R If T = 7 and the letter O represents an even number, what is the only possible value for W """ 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 => FD = [T,W,O,F,U,R], FD:: 0..9, T #= 7, F #> 0, all_different(FD), 2 * (100*T + 10*W + O) #= 1000*F + 100*O + 10*U + R, O mod 2 #= 0, solve(FD), printf("%d%d%d + %d%d%d == %d%d%d%d (W=%d)\n",T,W,O, T,W,O, F,O,U,R, W), fail, nl.