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?
-
Brian Gladman permalink123456789101112131415161718192021# volume of cake = c * side ** 3c = 2 * (1 + 2 ** (1/2))# the side length of the octagon - less than# (1200 / (2 + 2 ** (1/2)))^(1/3)for side in range(1, 7):# the total number (except mum) at the partyfor n in range(8, 13):# the cake volumevol = c * side ** 3# the two digit shareshare = int(vol / n)if 10 <= share < 100:# mum's sharemum = vol - n * share# mum's share is less but equal if one less or one more# person is at the partyif vol % (n - 1) == vol % (n + 1) < mum:print(f"{share} ounces (side length = {side}, {n - 1} guests)")
-
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")