Drill

ProblemsTypeScript › scheduling

How many breaks does the shift need

easyschedulingTypeScript

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

Solve it in the editor →

Where you start

function breakCount(lengthMinutes: number): number {
  
}

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 TypeScript
function breakCount(lengthMinutes: number): number {
  if (lengthMinutes < 240) return 0;
  return Math.floor(lengthMinutes / 240);
}

The same problem in another language

More scheduling problems in TypeScript