Drill

ProblemsPython › production

How busy was the line

mediumproductionPython

A shift board shows what share of the planned time the line was actually running.

utilisation_percent(run_minutes: int, planned_minutes: int) → int

Solve it in the editor →

Where you start

def utilisation_percent(run_minutes: int, planned_minutes: int) -> int:
    

Worked examples

CallResult
utilisation_percent(420, 480)88
utilisation_percent(480, 480)100
utilisation_percent(500, 480)100
utilisation_percent(0, 480)0

Hint

Round first, then cap. Capping first hides the rounding.

Reference solution in Python
def utilisation_percent(run_minutes: int, planned_minutes: int) -> int:
    if planned_minutes <= 0 or run_minutes <= 0:
        return 0
    pct = (run_minutes * 100 + planned_minutes // 2) // planned_minutes
    return min(100, pct)

The same problem in another language

More production problems in Python