# Sunday Times Teaser 2953 – Marble Tower

*by Andrew Skidmore*

#### Published April 28 2019 (link)

Liam has a number of bags of marbles; each bag contains the same number (more than 1) of equal-size marbles.

He is building a tetrahedron with the marbles, starting with a layer which fits snugly in a snooker triangle. Each subsequent triangular layer has one fewer marble along each edge. With just one bag left he had completed a whole number of layers; the number of marbles along the edge of the triangle in the last completed layer was equal to the number of completed layers. The last bag had enough marbles to just complete the next layer.

How many bags of marbles did Liam have?

3 Comments
Leave one →

Here is a manual solution.

When the number of layers equals the side length, let the start and end side lengths be \(n\) and \(m\) respectively. Hence \[n-m+1 = m \implies n = 2m – 1\] The number of marbles in the partial tetrahedron is \[n(n + 1)(n + 2)/6 \;-\; (m – 1)m(m + 1)/6\]Substituting for \(n\) and rearranging now gives: \[(m/6)(7m^2 – 1)\]The extra layer has \(m(m – 1)/2\) marbles, a number which divides the number of marbles in the partial tetrahedron to give \(b\), the number of bags used so far:\[b=\frac{(7m^2 – 1)}{ 3(m – 1)}\] After some magical rearrangement this becomes:\[(3b – 14)^2 – (14m – 3b)^2 = 168\]Now, denoting the squared terms as \(p\) and \(q\), and letting \(f\) be any factor of 168, we can equate the factors on the two sides of this equation to obtain: \[\begin{eqnarray}p-q\;&=&f\\p+q\;&=&168/f\end{eqnarray}\] We can now solve for \(p\) and \(q\) in terms of \(f\) to give\[\begin{eqnarray}2p\;&=&6b-28\;&=&f + 168/f\\2q\;&=&28m-6b\;&=&168/f-f\end{eqnarray}\] which gives \(b\) and \(m\) as\[\begin{eqnarray}b\;&=&(28 + f + 168/f)/6\\m\;&=&12/f+1\end{eqnarray}\]This gives two solutions \(b=9\) and \(b=19\). But the \(b=9\) solution has only 1 marble per bag. So, with the extra bag for the final layer, there were 20 bags of 21 marbles stacked in layers with side lengths from 6 to 13 inclusive.

Here is Python solution based on this analysis (using my number theory library available here):