Sunday Times Teaser 3129 – Bounce Count
by Mark Valentine
Published Sunday September 11 2022 (link)
At the local arcade, Claire and David played an air hockey game, consisting of a square table with small pockets at each corner, on which a very small puck can travel 1m leftright and 1m updown between the perimeter walls. Projecting the puck from a corner, players earn a token for each bounce off a wall, until the puck drops into a pocket.
In their game, one puck travelled 1m farther overall than its leftright distance (for the other, the extra travel was 2m). Claire’s threedigit number of tokens was a cube, larger than David’s number which was trianglular (1+2+3+…). Picking up a spare token, they could then arrange all their tokens into a cube and a square combined.
How many tokens did they end up with?

John Z. permalink12345678910111213141516171819202122232425262728293031# cubescs = tuple(i * i * i for i in range(1, 12))# triangular numbersts = tuple(j * (j+1) // 2 for j in range(1, 38))# tokens = horizontal distance  1 + vertical distance  1# tokens if overall distance (hypotenuse) == horizontal + 1t1s = tuple(i + int(i1)  2 for i in range(1, 300)if (i1 := ((i + 1) ** 2  i ** 2) ** (1 / 2)) == int(i1))# tokens if overall distance == horizontal + 2t2s = tuple(i + int(i2)  2 for i in range(1, 300)if (i2 := ((i + 2) ** 2  i ** 2) ** (1 / 2)) == int(i2))# consider tokens where "one puck travelled 1m farther overall..."for t1 in t1s:# consider tokens where "one puck travelled 2m farther overall..."for t2 in t2s:if ((t2 > t1 and t1 in ts and t2 in cs[4:9]) or(t1 > t2 and t1 in cs[4:9] and t2 in ts)):# sum Claire and David's tokens; add 1tokens = t1 + t2 + 1for k in cs:if tokens  k > 0 and (tksr := (tokens  k) ** 0.5) == int(tksr):print('Tokens:', t1, t2, 'cube:', k, 'square:', tokens  k)