/* Hundred Fowls puzzle in Picat. From Formula One sample: http://www.f1compiler.com/samples/Hundred%20Fowls.f1.html """ Hundred Fowls Puzzle In the late fifth and early sixth century, a Chinese mathematician Qiujian Zhang (Chang Ch'iu-chien) published a mathematics book, and in Chapter 38 he posed a hundred-fowl problem as follows: Assume that a cock is worth 5 coins each, a hen 3 coins, and three chicks together 1 coin, and that one buys 100 fowls with 100 coins, then how many cocks, hens and chicks are there respectively? """ 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 ?=> Cock :: 0..100, Hen :: 0..100, Chicks :: 0..100, % 5*cock + 3*hen + three_chicks/3 = 100 3 * 5 * Cock + 3 * 3 * Hen + Chicks #= 100*3, % multiply by 3 3 * Cock + 3 * Hen + 3 * Chicks #= 3*100, Chicks mod 3 #= 0, solve([Cock,Hen,Chicks]), println([cock=Cock,hen=Hen,chicks=Chicks]), fail, nl. go => true.