Sunday Times Teaser 2976 – Piece of Cake
by Stephen Hogg
Published October 6 2019 (link)
Using her special recipe, so that each cubic inch of baked cake weighed one ounce, Mam made the cake for my eighth birthday party. It had a regular octagonal flat top and base, and equal square vertical faces, several inches high exactly.
Not all (but a majority) of the dozen invited pals came to the party. We each had an equal portion of cake (the largest whole number of ounces possible from it, a two-figure number). Mam had the leftover cake. Curiously, if one more or one fewer pal had turned up and our portions had been worked out in the same way, Mam’s leftover would have been the same in each case, but less than she actually got.
How large, in ounces, was my portion?
-
GeoffR permalink12345678910111213141516# A cake side of 7 inches is 1656 cubic inches,# which is more than 12 no. 2-digit portionsfor s in range(2, 7):v = 2 * (1 + 2 ** 0.5) * s ** 3# a majority of a dozen pals came to the partyfor pals in range(8, 13):# find cake portion for each palp = v // palsif 10 <= p < 100:mam = v - pals * pif v % (pals - 1) == v % (pals + 1) < mam:print(f"Cake side = {s} inches, Cake volume = {v:.2f} cubic inches")print(f"My portion = {p} ounces, mam's portion = {mam:.2f} ounces")