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.
BreakCount(lengthMinutes: int) → int
C# needs a compiler and Drill does not host one yet, so this page is the reference rather than an exercise: the problem, worked examples, and the solution in full. To type it out, the same problem runs in Python.
Where you start
public int BreakCount(int lengthMinutes) {
}
Worked examples
| Call | Result |
|---|---|
BreakCount(120) | 0 |
BreakCount(240) | 1 |
BreakCount(241) | 1 |
BreakCount(480) | 2 |
Hint
Integer-divide the minutes by 240.
Reference solution in C#
public int BreakCount(int lengthMinutes) {
if (lengthMinutes < 240) return 0;
return lengthMinutes / 240;
}