/* One Landlord and 100 servants puzzle in Picat. From Danesi: """ A certain head of a household had 100 servants. He ordered that they be given 100 modia of corn as follows. The men should receive 3 modia; the women, 2; and the children, half a modium. Thus how many men, women, and children were there? """ Assuming that some man, woman, and child get atleast one modia of corn there are 6 solutions [men = 2,women = 30,children = 68] [men = 5,women = 25,children = 70] [men = 8,women = 20,children = 72] [men = 11,women = 15,children = 74] [men = 14,women = 10,children = 76] [men = 17,women = 5,children = 78] If we allow that some group gets nothing there is a seventh solution: [men = 20,women = 0,children = 80] This model was created by Hakan Kjellerstrand, hakank@gmail.com See also my Picat page: http://www.hakank.org/picat/ */ import cp. main => go. go ?=> Men :: 1..100, Women :: 1..100, Children :: 1..100, 100 #= Men + Women + Children, % This works 100 #= 3*Men + 2*Women + Children div 2, Children mod 2 #= 0, % And this works as well % 200 #= 6*Men + 4*Women + Children, solve([Men,Women,Children]), println([men=Men,women=Women,children=Children]), fail, nl. go => true.