Int 3 for Programmers
The car park meter
A car park has a sign with three rules on it. The first 20 minutes are free. After that you pay 150 pence for every hour you have been there, counting a part hour as a whole one. Nobody ever pays more than 900 pence in a day.
Write parking_cost(minutes), which returns the charge in pence for a stay of that many minutes.
Worked example, with minutes = 400. That is more than 20, so the free rule does not apply. 400 minutes is 6 hours and 40 minutes, and a part hour counts as a whole one, so it is charged as 7 hours: pence. That is above the daily cap, so the answer is 900.
Second worked example, with minutes = 21. That is past the free period, and 21 minutes counts as one started hour, so the answer is 150.
minutes is between 0 and 1440 inclusive.Run your code to see how it does on the examples. Submit also runs the hidden cases.