Premier League Predictor: FastAPI & Redis — Chapter 8, Exercise 3 ================================================================= TASK Compute the guest average in hundredths and in sixtieths for guest sets scoring [10,40,0], [40,10,10,0,0] and seven guests [10,0,0,0,0,0,0]. Report the rounding error of each, and explain why the sixtieths scheme stops working at seven guests. SOLUTION [10, 40, 0] exact 50/3 hundredths: round(1666.67) = 1667 error 0.3333 hundredths (0.0033 points) sixtieths: 50*60/3 = 1000 exact (an integer) [40, 10, 10, 0, 0] exact 12 hundredths: 1200 exact sixtieths: 60*60/5 = 720 exact [10, 0, 0, 0, 0, 0, 0] exact 10/7 hundredths: round(142.857) = 143 error 0.1429 hundredths sixtieths: 10*60/7 = 600/7 = 85.71... NOT an integer Why it stops at seven: every prediction is worth 0, 10 or 40, so the sum of guest points is a multiple of 10. Multiplying by 60 makes it a multiple of 600. An integer average needs 600 to divide evenly by the number of guests. 600 is divisible by 1, 2, 3, 4, 5 and 6, but not by 7. Checked on 200 random cases for each guest count from 1 to 6: always a whole number. The scheme is exact for a week with up to six guests, and not beyond. For any guest count, a common denominator would be needed (for example 420 covers 1 to 7), at the cost of a larger integer. Otherwise a rare seven-guest week still gets a rounding error, as hundredths always do. WHY THIS WORKS AS AN ANSWER ---------------------------- It works the three cases with the real arithmetic, explains the limit from the actual divisibility argument, and states exactly where the sixtieths scheme is and is not safe.