Finished units in a shift
A production planner works out how much good product a shift turns out: run time at a rate, less scrap.
- Run time is the shift minus the breaks, in minutes.
- Units per hour are applied to that run time, truncated down.
- Finally scrap percent leaves only the finished units, again truncated down.
ShiftOutput(perHour: int, shiftMinutes: int, breakMinutes: int, scrapPercent: 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.
Where you start
public int ShiftOutput(int perHour, int shiftMinutes, int breakMinutes, int scrapPercent) {
}
Worked examples
| Call | Result |
|---|---|
ShiftOutput(360, 480, 30, 10) | 2430 |
ShiftOutput(60, 120, 0, 0) | 120 |
ShiftOutput(360, 480, 480, 0) | 0 |
ShiftOutput(60, 390, 30, 25) | 270 |
Hint
Do the truncation at each step: first production, then finished.
Reference solution in C#
public int ShiftOutput(int perHour, int shiftMinutes, int breakMinutes, int scrapPercent) {
int production = ((shiftMinutes - breakMinutes) * perHour) / 60;
return (production * (100 - scrapPercent)) / 100;
}