/* Added corner puzzle in Picat. Problem from http://www.delphiforfun.org/Programs/AddedCorners.htm """ This puzzle requires that you enter the digits 1 through 8 in the circles and squares (one digit in each figure) so that the number in each square is equal to the sum on the numbers in the circles which adjoin it. ... C F C F F C F C """ Model created by Hakan Kjellerstrand, hakank@gmail.com See also my Picat page: http://www.hakank.org/picat/ */ import cp. main => go. go => L = findall(X, $added_corner(X)), writef("It was %d solutions.\n", length(L)). added_corner(X) => Digits = 1..8, X = [A,B,C,D,E,F,G,H], X :: Digits, all_different(X), B #= A + C, D #= A + F, E #= C + H, G #= F + H, solve(X), writef("%d %d %d\n", A,B,C), writef("%d %d\n", D,E), writef("%d %d %d\n", F,G,H), nl.