/* A star puzzle in Picat. From Adrian Groza "Modelling Puzzles in First Order Logic" """ Puzzle 119. A star Can you place the integers from 1 through 12 in the circles of the six-pointed star so that the sum of the numbers in each of the six rows is 26? (puzzle 324 from Kordem- sky (1992)) """ There are 80 solutions (with X[1] #= 1). Here are some of them [1,2,4,12,8,10,6,11,5,3,7,9] [1,2,6,10,8,12,4,7,3,5,11,9] [1,2,7,11,6,8,5,10,4,3,9,12] ... [1,10,7,5,4,6,11,12,2,3,9,8] [1,11,6,5,4,10,12,9,2,7,8,3] [1,11,8,4,3,7,12,10,2,5,9,6] With the symmetry breaking increasing(X[1..6]) and X[1] = 1, there are three solutions: [1,3,4,8,11,12,7,9,5,2,10,6] [1,4,5,6,11,12,10,8,7,2,9,3] [1,4,5,7,10,11,6,9,3,2,12,8] 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 => N = 12, X = [X1,X2,X3,X4,X5,X6,X7,X8,X9,X10,X11,X12], X :: 1..N, all_different(X), X1 + X3 + X6 + X8 #= 26, X1 + X4 + X7 + X11 #= 26, X2 + X3 + X4 + X5 #= 26, X2 + X6 + X9 + X12 #= 26, X5 + X7 + X10 + X12 #= 26, X8 + X9 + X10 + X11 #= 26, % Symmetry breaking X[1] #= 1, increasing(X[1..6]), solve(X), println(X), fail, nl.