/* Birthdays puzzle in Picat. This is a true story: In this year 2010 my older brother Anders will be the same age as the year I was born in the last century, and I will be the same age as the year he was born in the last century. My brother is four years older than me. How old are we this year (i.e. year of 2010)? 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 = [H,A], L :: 1..100, H+A #= 110, A-H #= 4, solve(L), println(L), fail, nl. go => true. % % Here is a much more elaborated model. % go2 ?=> X = [HakanBorn,AndersBorn,HakanAge,AndersAge], X :: 1..100, ThisYear :: 100..200, HakanAge #= ThisYear - HakanBorn, AndersAge #= ThisYear - AndersBorn, HakanBorn #> AndersBorn, HakanAge #= AndersBorn, AndersAge #= HakanBorn, HakanBorn - AndersBorn #= 4, ThisYear #= 110, solve(X), println([thisYear=ThisYear,hakanBorn=HakanBorn,andersBorn=AndersBorn,hakanAge=HakanAge,andersAge=AndersAge]), fail, nl. go2 => true.