/* Tommy's Birthday Coins coins puzzle in Picat. From Martin Chlond Integer Programming Puzzles: http://www.chlond.demon.co.uk/puzzles/puzzles2.html, puzzle nr. 2. Description : Tommy's Birthday Coins Source : Clarke, L.H., (1954), Fun with Figures, William Heinemann Ltd. """ 2. Tommy was given 15 coins for his birthday, all in half-crowns, shillings and sixpences. When he added it up he found that he had 1 5s. 6d. How many half-crowns was he given? (Clarke) """ Answer: 8 half-crowns, 4 shillings and 3 sixpences This model was inspired by the XPress Mosel model created by Martin Chlond. http://www.chlond.demon.co.uk/puzzles/sol2s2.html 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 => Coin = 3, C = 1..Coin, Value = [30,12,6], X = new_list(Coin), foreach(I in C) X[I] #>= 1 end, sum([Value[I]*X[I] : I in C]) #= 306, sum(X) #= 15, solve(X), writeln(X), nl.