Sunday Times Teaser 2912 – Be Crafty and Box Clever
by Stephen Hogg
Published July 15 2018 (link)
Tyson, a crafter, had several cylindrical enclosed boxes (with heights equal to diameters) in two sizes. Each box’s surface area (including top and bottom) was a three-figure integer in square centimetres, and the larger boxes had a radius which was a whole number multiple of that of the smaller boxes.
He kept them all in one vertical stack, to within one centimetre of the top of their metre-deep storage bin. Whilst working out fabric-cutting schemes, Tyson found that all the bigger boxes’ surface areas combined equalled all the smaller boxes’ surface areas combined and that the total surface area (in square centimetres) of all the boxes had all its numerals in ascending order.
What was the total surface area of all the boxes, in square centimetres?
-
Brian Gladman permalink1234567891011121314151617181920212223242526272829303132333435363738from itertools import countfrom math import pi# check that the decimal digits in a string are in ascending order left to rightis_ascending = lambda s: all(s[i] < s[i + 1] for i in range(len(s) - 1))# a closed cylindrical box of diameter and height x# has a surface area (A) of (3/2).pi.x^2d2a = 3 * pi / 2# let m be the ratio of the radii of the two boxes# giving a surface area ratio of m^2 (note that m# < 4 since both boxes have 3 digit surface areas)for m in (2, 3):# consider the three digit surface area of the smaller# box such that the larger box also has a three digit# surface areafor s_area in range(100, 999 // m ** 2 + 1):# the smaller box diameter and heights_d = (s_area / d2a) ** (1 / 2)# compute the size and the surface area of the larger boxl_d, l_area = m * s_d, m * m * s_area# consider the number of larger blocksfor nl in count(1):# the number of smaller blocksns = m * m * nl# the height of the stackh = ns * s_d + nl * l_dif h > 100:breakif h >= 99:# the total surface area has its digits in ascending ordersa = ns * s_area + nl * l_areaif is_ascending(str(sa)):print(f'Total surface area = {sa} cm^2 'f'({ns} x {s_area} cm^2, {nl} x {l_area} cm^2).')