Problems › Python › scheduling
How many breaks does the shift need
Labour law requires a 30-minute rest after every four hours on the floor. Count the mandatory breaks a shift of lengthMinutes earns.
- Four full hours (240 minutes) earns the first break, eight hours the second, and so on.
- A shift of exactly 240 minutes gets one break, not two.
break_count(length_minutes: int) → int
Where you start
def break_count(length_minutes: int) -> int:
Worked examples
| Call | Result |
|---|---|
break_count(120) | 0 |
break_count(240) | 1 |
break_count(241) | 1 |
break_count(480) | 2 |
Hint
Integer-divide the minutes by 240.
Reference solution in Python
def break_count(length_minutes: int) -> int:
if length_minutes < 240:
return 0
return length_minutes // 240