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.
shift_output(per_hour: int, shift_minutes: int, break_minutes: int, scrap_percent: int) → int
Where you start
def shift_output(per_hour: int, shift_minutes: int, break_minutes: int, scrap_percent: int) -> int:
Worked examples
| Call | Result |
|---|---|
shift_output(360, 480, 30, 10) | 2430 |
shift_output(60, 120, 0, 0) | 120 |
shift_output(360, 480, 480, 0) | 0 |
shift_output(60, 390, 30, 25) | 270 |
Hint
Do the truncation at each step: first production, then finished.
Reference solution in Python
def shift_output(per_hour: int, shift_minutes: int, break_minutes: int, scrap_percent: int) -> int:
production = (shift_minutes - break_minutes) * per_hour // 60
return production * (100 - scrap_percent) // 100