Here’s one of my favorite logic puzzles.

Two friends, a programmer and a mathematician, get together for drinks after work one day at the programmer’s house. The mathematician asks the programmer how his three children are doing. The programmer replies that one of his three children just had a birthday.

The mathematician then asks, “How old are your children now?” The programmer answers, “The product of their ages is 36.” The mathematician thinks for a moment and says, “That’s not enough information.” The programmer says, “OK then, the sum of their ages equals my house street address number.” The mathematician steps outside to check the address number, comes back inside, and says, “That’s still not enough information.” The programmer then says, “Well my oldest child has red hair.”

The mathematician immediately responded, “Oh, now I know the ages!” and told the programmer what the ages were. What are the ages of the programmer’s three children?

The children are aged 2, 2, and 9 years old (there are two-year old twins). The mathematician’s logic was that since there are three children whose ages multiply to 36, the eight possible combinations are:

1, 1, 36 1, 2, 18 1, 3, 12 1, 4, 9 1, 6, 6 2, 2, 9 2, 3, 6 3, 3, 4

Initially, any of these combinations could be the correct ages. After the programmer says that the sum of the ages is the same as the house address, the mathematician mentally computed the sum of each possible combination:

1, 1, 36 sum = 38 1, 2, 18 sum = 21 1, 3, 12 sum = 16 1, 4, 9 sum = 14 1, 6, 6 sum = 13 2, 2, 9 sum = 13 2, 3, 6 sum = 11 3, 3, 4 sum = 10

Notice that all the sums are different except for (1, 6, 6) and (2, 2, 9) which both sum to 13. If the programmer’s address was anything except for 13, then the mathematician would know the ages, so the three ages must be one of those two combinations that sum to 13. But after the programmer said that the oldest child has red hair, the mathematician knew that there was a single oldest child which eliminates the (1, 6, 6) combination which has oldest twins, leaving just (2, 2, 9) as the ages of the children.

Neat!