Sunday Times Teaser 3241 – Users Pay
by Howard Williams
Published Sunday November 03 2024 (link)
I live in a cul-de-sac which had planning permission for building on ten identical plots along the whole length of one side of the road. The developer started building, and numbered the properties, from the closed end. The plots aren’t all finished, and the cost of surfacing the whole road has to be paid by the owners of the completed properties. It was decided that the owners would only contribute to the cost of the road leading to their property, so the owner of number 1 pays for the road section in front of their property, the cost of the section outside number 2 is shared equally between numbers 1 and 2, and so on.
My contribution is £1,000, while that of another homeowner is £3,800.
What is my house number and how many houses have been built?
I didn’t understand how this one worked until Jim Randell explained it here.
Interestingly, in my code above, replacing the integer division (double slash) operations with floating point (single slash) operations and setting the unit cost to 1 gives the same result. I realize, of course, that rounding errors can creep in with floating point that prevent getting a (correct) result.