/* The Digital Atom Smasher (alphametic problem) in Picat. From http://www.math.uni-bielefeld.de/~sillke/PUZZLES/ALPHAMETIC/ """ sqrt(ATOM) = A + TO + M this has two solutions Ref: Angela Fox Dunn, Mathematical Bafflers, 1980, p39 """ This Picat model was created by Hakan Kjellerstrand, hakank@gmail.com See also my Picat page: http://www.hakank.org/picat/ */ import cp. main => go. go ?=> X = [A,T,O,M], X :: 0..9, ATOM #= 1000*A+100*T+10*O+M, TO #= 10*T+O, Z :: 0..1000, Z * Z #= ATOM, all_different(X), Z #= A + (10*T+O) + M, solve(X ++ [Z]), println(X), println("ATOM = A + TO + M:"), printf("%w = %w + %w + %w\n",ATOM,A,TO,M), nl, fail, nl. go => true.