Drill

ProblemsPython › scheduling

Total minutes scheduled

easyschedulingPython

A weekly grid lists every shift as a start and end in minutes past midnight. Add up the committed hours.

shift_total(shifts: list<Shift>) → int

Solve it in the editor →

Where you start

def shift_total(shifts: list[Shift]) -> int:
    

Worked examples

CallResult
shift_total([Shift(start=480, end=900), Shift(start=900, end=1080)])600
shift_total([Shift(start=0, end=1440)])1440
shift_total([])0
shift_total([Shift(start=600, end=600)])0

Hint

Sum of (end - start).

Reference solution in Python
def shift_total(shifts: list[Shift]) -> int:
    return sum(s.end - s.start for s in shifts)

The same problem in another language

More scheduling problems in Python