Problem 180197 · medium · Level 01 Prerequisites & Setup

Car Park Fee

conditionals · integer arithmetic

A car park charges as follows. Write parking_fee(minutes):

  • the first 15 minutes are free (a stay of 15 minutes or less costs 0),
  • otherwise the first hour (or any part of it) costs 3,
  • every further hour or part of an hour costs 2,
  • the fee for a single day never exceeds 20.

Examples

Input:  minutes = 10
Output: 0

Input:  minutes = 60
Output: 3

Input:  minutes = 61
Output: 5

Input:  minutes = 600
Output: 20
Explanation: 10 hours would be 3 + 9 * 2 = 21, capped at 20.

Constraints

  • 0 <= minutes <= 1440 (integer)

Goals

  • Combine a grace period, a per-hour rule and a daily cap
  • Round minutes up to whole hours with integer arithmetic
Starting Python…