Int 3 for Programmers

The car park meter

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: 150×7=1050150 \times 7 = 1050 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.

  • Constraints: minutes is between 0 and 1440 inclusive.
  • A stay of exactly 20 minutes is free. A stay of 21 minutes is not.
  • Rounding a part hour up is the ceiling, not ordinary rounding: 61 minutes is charged as 2 hours, not 1.
  • The cap applies after the hourly charge has been worked out.
Code

Run your code to see how it does on the examples. Submit also runs the hidden cases.