/* Three squares puzzle in Picat. From Adrian Groza "Modelling Puzzles in First Order Logic" """ Puzzle 5. Three squares Find three distinct squares such that one is the arithmetic mean of the other two. (puz- zle taken from www.mathisfun.com) """ Here are some solutions: [1,25,49] [4,100,196] [9,225,441] [16,400,784] [49,169,289] [49,289,529] [289,625,961] 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 ?=> [A,B,C,AA,BB,CC] = X, X :: 1..1000, AA #= A*A, BB #= B*B, CC #= C*C, 2*BB #= AA+CC, A #< C, solve(X), println([AA,BB,CC]), fail, nl. go => true.