/* Mama's age problem in Picat. Mamma's Age from "Amusements in Mathematics, Dudeney", number 40. """ Tommy: "How old are you, mamma?" Mamma: "Our three ages add up to exactly seventy years." Tommy: "And how old are you, papa?" Papa: "Just six times as old as you, my son." Tommy: "Shall I ever be half as old as you, papa?" Papa: "Yes, Tommy; and when that happens our three ages will add up to exactly twice as much as today." Can you find the age of Mamma? """ Model created by Hakan Kjellerstrand, hakank@gmail.com See also my Picat page: http://www.hakank.org/picat/ */ import cp. main => go. go => mama([M,P,T]), MY = M // 12, PY = P // 12, TY = T // 12, writeln([mama=M=MY,papa=P=PY,tommy=T=TY]). mama(LD) => LD = [M,P,T], LD :: 0..500, M + P + T #= 70 * 12, 6 * T #= P, (T + I) * 2 #= P + I, M + I + P + I + T + I #= 2 * (M + P + T), solve(LD).