/* Joe's Pyramid (Enigma 1631) in Picat. http://www.newscientist.com/article/mg20927971.100-enigma-number-1631.html#.VHDqdIXgjR4 """ Enigma 1631 - Joe's pyramid New Scientist magazine, 29 January 2011. By Bob Walker. Joe's Pyramid This is Joe's pyramid. Every stone is marked with a different one or two digit positive number. [ [X] [ ][ ] [ ][ ][ ] [ ][ ][ ][ ] [ ][ ][ ][ ][ ] [ ][ ][ ][ ][ ][ ] represented as 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 ] Where a stone rests on two others, its number is the sum of the numbers marked on the two stones on which it rests. What number is X? """ There is only two solutions, both have X = 98 98, 46, 52, 26, 20, 32, 17, 9, 11, 21, 12, 5, 4, 7, 14, 10, 2, 3, 1, 6, 8] ---------- [98, 52, 46, 32, 20, 26, 21, 11, 9, 17, 14, 7, 4, 5, 12, 8, 6, 1, 3, 2, 10] ---------- ========== 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 = 21, X = new_list(N), X :: 0..99, all_different(X), X[1] #= X[2] + X[3], X[2] #= X[4] + X[5], X[3] #= X[5] + X[6], X[4] #= X[7] + X[8], X[5] #= X[8] + X[9], X[6] #= X[9] + X[10], X[7] #= X[11] + X[12], X[8] #= X[12] + X[13], X[9] #= X[13] + X[14], X[10] #= X[14] + X[15], X[11] #= X[16] + X[17], X[12] #= X[17] + X[18], X[13] #= X[18] + X[19], X[14] #= X[19] + X[20], X[15] #= X[20] + X[21] , solve($[degree],X), println(X), fail, nl. go => true.