/* Grime puzzle in Picat. From Travels in a mathematical world "A puzzle from James Grime about abcdef" http://travels.peterrowlett.net/2012/02/puzzle-from-james-grime-about-abcdef.html """ Today James Grime tweeted this question/puzzle: Is there a six digit number abcdef such that the following all hold? a+b+c+d+e+f = y ab+cd+ef=10y abc+def=100y If not, show why not. A little tweeting back and forth verified that "ab" means 10a+b not a×b. """ [x = [1,0,0,0,0,0],y = 1] [x = [2,0,0,0,0,0],y = 2] [x = [3,0,0,0,0,0],y = 3] [x = [4,0,0,0,0,0],y = 4] [x = [5,0,0,0,0,0],y = 5] [x = [6,0,0,0,0,0],y = 6] [x = [7,0,0,0,0,0],y = 7] [x = [8,0,0,0,0,0],y = 8] [x = [9,0,0,0,0,0],y = 9] I.e. Y = A. 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,B,C,D,E,F], X :: 0..9, A #> 0, Y #= sum(X), (10*A+B) + (10*C+D) + (10*E+F) #= 10*Y, (100*A+10*B+C) + (100*D+10*E+F) #= 100*Y, solve(X), println([x=X,y=Y]), fail, nl. go => true.