/* Chandelier Balancing (PuzzlOR) in Picat. http://puzzlor.editme.com/balance """ Constructing a chandelier can be a tricky undertaking because the slightest imperfection will unbalance the chandelier and cause it to be skewed. Figure 1 [see site above] shows a chandelier constructed from arms, wires, and triangles that hold weights. In order to perfectly balance the chandelier, weights must be placed into the triangles. There are 9 weights as follows: 1,2,3,4,5,6,7,8,9kg. Each triangle can only hold one weight. Assume the weight of the arms, wires, and triangles are negligible. Question: Where should the weights be placed in order to perfectly balance the chandelier? """ 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 ?=> N = 9, L = [A,B,C,D,E,F,G,H,I], L :: 1..N, Total #= sum(L), all_different(L), 2*A #= 1*B+2*C, 2*D+1*E #= 1*F, 2*G+1*H #= 3*I, 3*(A+B+C) #= 2*(D+E+F)+3*(G+H+I), solve(L), println(L), fail, nl. go => true.