by Edmund Marshall

Published Sunday September 04 2022 (link)

I have a large number, fewer than 2000, of identical spherical bonbons, arranged exactly as a tetrahedral tower, having the same number of bonbons along each of the six edges of the tower, with each bonbon above the triangular base resting on just three bonbons in the tier immediately below.

I apportion all my bonbons between all my grandchildren, who have different ages in years, not less than 5, so that each grandchild can exactly arrange his or her share as a smaller tetrahedral tower, having the same number of tiers as his or her age in years.

The number of my grandchildren is the largest possible in these circumstances.

How many tiers were in my original tower, and how old in years are the eldest and youngest of my grandchildren?

From → Uncategorized

Faster:

This could be made faster by assuming a smaller maximum number of grandchildren, say 12 instead of 16.

Hi John,

You can also get a significant speed gain by changing line 13 to:

I noticed a bug in my code: the age of the eldest granchild would not be calculated correctly if the ages from youngest to eldest were non-consecutive. They are consecutive in this teaser so the bug doesn’t prevent a ‘right’ answer. Here is the corrected code with the speed improvement suggested by Brian and one of my own in two additional lines of code.

Nice solution.

It does not cater for the fact that for the same number of grandchildren there might be multiple solutions (and you only print one). I know that there is supposed to be one solution but printing all possible solutions has my preference.

The program would be very fast when you determine the maximum number of grandchildren first instead of using a hardcoded 16. This 0/1 approach seems to lend itself to bit logic (I am not very good at it).