/*
Coins puzzle in Picat.
From Martin Chlond Integer Programming Puzzles:
http://www.chlond.demon.co.uk/puzzles/puzzles1.html, puzzle nr. 2
Description : Coin puzzle
Source : Mathematical Puzzles of Sam Loyd (P111)
"""
Supposing that eleven coins with round holes are worth 15 bits, while eleven square
ones are worth 16 bits, and eleven of triangular shape are worth 17 bits, tell
how many round, square or triangular pieces of cash would be required to purchase
an item worth eleven bits.
(Loyd)
"""
This model was inspired by the XPress Mosel model created by Martin Chlond.
http://www.chlond.demon.co.uk/puzzles/sol1s2.html
This Picat model was created by Hakan Kjellerstrand, hakank@gmail.com
See also my Picat page: http://www.hakank.org/picat/
*/
% import util.
import cp.
main => go.
go =>
V = [15,16,17],
Requ = 121, % i.e. 11 * 11
N = 3,
% decision variables
X = new_list(N),
foreach(I in 1..N)
X[I] #>= 0
end,
Requ #= sum([V[I]*X[I] : I in 1..3]),
Z #= sum(X),
solve($[min(Z)],X),
% solve(X),
println(x=X),
println(z=Z),
nl.