/* Age problem in Picat. Problem from CTK Insights "When Two Wrongs Make One Right" http://www.mathteacherctk.com/blog/2012/04/when-two-wrongs-make-one-right/ """ John is twice as old as Jim; the sum of their ages is that of Jerry's, while the ages of the three of them add up to 36. How old is each? """ 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 ?=> L = [John, Jim, Jerry], L :: 0..36, % John is twice as old as Jim John #= Jim*2, % the sum of their ages is that of Jerry's, John + Jim #= Jerry, % while the ages of the three of them add up to 36. John + Jim + Jerry #= 36, solve(L), println([john=John,jim=Jim,jerry=Jerry]), fail, nl. go => true.