How many parcels missed the van
Items boarded the van if their ready time is before backstopMinutes. Count how many missed it, so the leftover list can be quoted again.
- ready times are in minutes past midnight.
- An item ready exactly at the backstop still boards.
late_parcels(ready_times: list<int>, backstop_minutes: int) → int
Where you start
def late_parcels(ready_times: list[int], backstop_minutes: int) -> int:
Worked examples
| Call | Result |
|---|---|
late_parcels([100, 200, 300], 250) | 1 |
late_parcels([250, 250], 250) | 0 |
late_parcels([300], 100) | 1 |
late_parcels([], 500) | 0 |
Hint
Count the ones that fail the comparison.
Reference solution in Python
def late_parcels(ready_times: list[int], backstop_minutes: int) -> int:
return sum(1 for t in ready_times if t > backstop_minutes)