/* Enigma puzzle 1396: Planets in Picat. Problem formulation from http://www.f1compiler.com/samples/Enigma%201396.f1.html """ Enigma 1396 W. Haigh, New Scientist magazine, 17 June 2006. I have allocated distinct positive integers to the letters of the alphabet. By adding up the values of the letters in their names, I have obtained the following scores for some members of the solar system: PLUTO 40, URANUS 36, NEPTUNE 29, SATURN 33, JUPITER 50, MARS 32, EARTH 31, MOON 36, VENUS 39, MERCURY 33, SUN 18. Please send in the value of PLANETS. """ 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 ?=> Letters = [P,L,U,T,O,R,A,N,S,E,I,M,J,H,V,C,Y], Letters :: 1..26, all_different(Letters), P + L + U + T + O #= 40, U + R + A + N + U + S #= 36, N + E + P + T + U + N + E #= 29, S + A + T + U + R + N #= 33, J + U + P + I + T + E + R #= 50, M + A + R + S #= 32, E + A + R + T + H #= 31, M + O + O + N #= 36, V + E + N + U + S #= 39, M + E + R + C + U + R + Y #= 33, S + U + N #= 18, P + L + A + N + E + T + S #= Planets, solve(Letters), println(letters=Letters), println(planets=Planets), nl, fail, nl. go => true.