/* Dividing the legacy puzzle in Picat. From Adrian Groza "Modelling Puzzles in First Order Logic" """ Puzzle 7. Dividing the legacy A man left 100 dollars to be divided between his two sons Alfred and Benjamin. If one-third of Alfred's legacy was taken from one-fourth of Benjamin's, the remainder would be 11 dollars. What was the amount of each legacy? (puzzle 15 from Dudeney 2016) """ [alfred = 24,benjamin = 76] This program was created by Hakan Kjellerstrand, hakank@gmail.com See also my Picat page: http://www.hakank.org/picat/ */ import cp. main => go. go ?=> [A,B] :: 1..100, (B div 4) - (A div 3) #= 11, A + B #= 100, solve([A,B]), println([alfred=A,benjamin=B]), fail, nl. go => true. % % Groza has an alternative version, not using div/2. % Same result: [24,76] % go2 ?=> [A,B] :: 1..100, (3 * B) + ((-4)*A) #= 11*12, A + B #= 100, % solve([A,B]), % not needed println([A,B]), fail, nl. go2 => true.