Skip to content

Sunday Times Teaser 3128 – Tetrahedral Towers

by BRG on September 2, 2022

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

8 Comments Leave one →
  1. Brian Gladman permalink

    Faster:

  2. Frits permalink

  3. John Z permalink

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

    • Brian Gladman permalink

      Hi John,

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

  4. John Z permalink

    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.

    • Frits permalink

      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).

  5. Frits permalink

    Only calling decompose twice from main loop.

  6. John Z permalink

    Thanks Frits. Here’s a version which addresses your concerns. By casting a very wide net it does a lot more calculation than we know is necessary. Generally, I strive to reduce the line count, sometimes sacrificing clarity and run time.

Leave a comment to John Z Cancel reply

Note: HTML is allowed. Your email address will not be published.

Subscribe to this comment feed via RSS