/* Enigma 1671 in Picat. https://enigmaticcode.wordpress.com/2011/11/30/enigma-1671-power-engineering/ From New Scientist #2837, 2nd November 2011 Read from left to right, the different digits in the number ENIGMA are in descending order, and not necessarily consecutive. Given that E^6 + NI^3 + GMA^2 = EENNGG, find ENIGMA. % Jim Randall's solution: Solution: ENIGMA = 876432. This Picat model was created by Hakan Kjellerstrand, hakank@gmail.com See also my Picat page: http://www.hakank.org/picat/ */ % import util. import cp. main => go. go => X = [E,N,I,G,M,A], X :: 1..9, all_different(X), decreasing(X), E**6 + (N*10+I)**3 + (G*100+M*10+A)**2 #= E*100000 + E*10000 + N*1000 + N*100 + G*10 + G, solve([ff,split], X), println(X), nl.