Drill

ProblemsGo › scheduling

How many breaks does the shift need

easyschedulingMathGo

Labour law requires a 30-minute rest after every four hours on the floor. Count the mandatory breaks a shift of lengthMinutes earns.

breakCount(lengthMinutes: int) → int

Go 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.

Solve it in Python →

Where you start

func breakCount(lengthMinutes int) int {
	
}

Worked examples

CallResult
breakCount(120)0
breakCount(240)1
breakCount(241)1
breakCount(480)2

Hint

Integer-divide the minutes by 240.

Reference solution in Go
func breakCount(lengthMinutes int) int {
	if lengthMinutes < 240 {
		return 0
	}
	return lengthMinutes / 240
}

The same problem in another language

More scheduling problems in Go