% % Birthdays puzzle in MiniZinc. % % 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? % % Note: Of course, this could be modelled in a much easier way. % % This MiniZinc model was created by Hakan Kjellerstrand, hakank@bonetmail.com % See also my MiniZinc page: http://www.hakank.org/minizinc % % include "globals.mzn"; var 1..100: hakank_born :: is_output; var 1..100: anders_born :: is_output; var 1..100: hakank_age :: is_output; var 1..100: anders_age :: is_output; var 100..200: this_year :: is_output; solve satisfy; % solve :: int_search(x, first_fail, indomain_min, complete) satisfy; constraint hakank_age = this_year - hakank_born /\ anders_age = this_year - anders_born /\ hakank_born > anders_born /\ hakank_age = anders_born /\ anders_age = hakank_born /\ hakank_born - anders_born = 4 /\ this_year = 110 ;