Drill

ProblemsC# › production

How busy was the line

mediumproductionMathC#

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

UtilisationPercent(runMinutes: int, plannedMinutes: 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.

Solve it in Python →

Where you start

public int UtilisationPercent(int runMinutes, int plannedMinutes) {
    
}

Worked examples

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

Hint

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

Reference solution in C#
public int UtilisationPercent(int runMinutes, int plannedMinutes) {
    if (plannedMinutes <= 0 || runMinutes <= 0) return 0;
    int pct = (runMinutes * 100 + plannedMinutes / 2) / plannedMinutes;
    return Math.Min(100, pct);
}

The same problem in another language

More production problems in C#