Rule Solver – Family Riddle

Problem Description. This problem is offered as a DMCommunity’s challenge Jan-2024.

children

Let’s assume that Rene and Leo are both heads of household, and, what a coincidence, both families include three girls and three boys. The youngest child in Leo’s family is a girl, and in Rene’s family, a little girl has just arrived. In other words, there is a girl in Rene’s family whose age is less than one year. Neither family includes any twins, nor any children closer in  age than a year. All the children are under age ten. In each family, the sum of the ages of the girls is equal to the sum of the ages of the boys; in fact, the sum of the squares of the ages of the girls is equal to the sum of the squares of the ages of the boys. The sum of the ages of all these children is 60.

QuestionWhat are the ages of the children in these two families? How many solutions has this problem?

Implementation. We will use the following business Glossary to describe the main concepts of the problem:

For every child in arrays ReneChildren and LeoChildren, Solver will create decision variables with possible values from 0 to 9 representing their ages.

We can represent both families in this DecisionData and DecisionTest tables:

We will use the standard Rule Solver top-level decision “DefineAndSolve”:

The table “Define” posts all constraints:

The table “Solve” finds and logs all possible solutions:

When we execute this decision model, we will receive one and only one solution: