/*
Fifty puzzle in Picat.
From Martin Chlond Integer Programming Puzzles:
http://www.chlond.demon.co.uk/puzzles/puzzles1.html, puzzle nr. 5.
Description : Fifty puzzle
Source : The Puzzles of Sam Loyd (P 54)
"""
5. A side show at Coney Island is described as follows: "There were ten little
dummies which you were to knock over with baseballs. The man said: 'Take as many
throws as you like at a cent apiece and stand as close as you please. Add up the
numbers on all the men that you knock down and when the sum amounts to exactly
fifty, neither more nor less you get a genuine 25 cent Maggie Cline cigar with
a gold band around it.'"
The numbers on the ten dummies were 15, 9, 30, 21, 19, 3, 12, 6, 25, 27. (Loyd)
"""
Answer: 6, 19 and 25
This model was inspired by the XPress Mosel model created by Martin Chlond.
http://www.chlond.demon.co.uk/puzzles/sol1s5.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 =>
N = 10,
V = [3, 6, 9, 12, 15, 19, 21, 25, 27, 30],
X = new_list(N),
X :: 0..1,
SumX #= sum(X),
sum([V[I]*X[I] : I in 1..N]) #= 50,
solve(X),
writeln(sumX=SumX),
writeln(x=X),
writeln(targets=[V[I] : I in 1..N, X[I]==1]),
nl.