From 3c451d256bb1ef9919fa021da22e6932da6d1cb8 Mon Sep 17 00:00:00 2001 From: David Pratten Date: Mon, 25 Sep 2023 08:39:11 +1000 Subject: [PATCH] Family Age Gaps --- puzzles/family_age_gaps.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/puzzles/family_age_gaps.md b/puzzles/family_age_gaps.md index 9381b37..81da3b2 100644 --- a/puzzles/family_age_gaps.md +++ b/puzzles/family_age_gaps.md @@ -2,6 +2,8 @@ The following puzzle is from Peter Revesz's 1993 paper "A closed-form evaluation for Datalog queries with integer (gap)-order constraints." _Theoretical Computer Science, 116(1), 117–149._ https://doi.org/10.1016/0304-3975(93)90222-F +## Problem + > Alfred and Alice have children Bernard, Carl and Donald in this order. Bernard and Bernice have a child Edward. Donald and Denise have children Elise and Fred. Edward and Elise have a child, Gerald. Fred and Felice have a child, Harold. @@ -10,7 +12,17 @@ month. Elise is over four years older than her younger brother Fred, and Bernard 25 years older than his son Edward. Assuming that there is over 17 years difference between parents and their children and that no siblings are twins or born in the same year, how old is Donald? -And here is a literate programming solution using a complete relation and SQL. +And here the solution with a literate programming query using a complete relation and SQL. + +## Solution + +| **Donald_age** | +| -- | +| 47 | +| 48 | +| 49 | + +## Relation Expression ```SQL SELECT Donald_age