/* Anteaters card puzzle in Picat. From Chris Smith's Maths Newsletter # 537 """ Five anteaters are drinking tea and playing a card game. Ten cards are on the table: 10,9,8,7,6,5,4,3,2 and Ace (representing 1). Each anteater takes two cards and adds to get a total. Here are some of their totals: Antyseptic: 11 Antyclimax: 7 Antynatal: 5 Antydote: 14 Can you work out the cards that each player had and come up with an anteater pun name for the fifth player? """ 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. % The original REPL version go ?=> X=new_list(10), X::1..10, X[1]+X[2]#=11, X[3]+X[4]#=7, X[5]+X[6]#=5, X[7]+X[8]#=14, % Symmetry X[1]# true. % Slighly more compact go2 ?=> X = new_list(10), X :: 1..10, S = [11,7,5,14], foreach(I in 0..3) X[I*2+1] + X[I*2+2] #= S[I+1], X[I*2+1] #< X[I*2+2] end, X[9] #< X[10], all_different(X), println(x=X), solve(X), println(X), fail, nl. go2 => true.