Spares to keep for a fleet
To scale a fleet safely, buying 10% extra units as spares keeps the line alive while one fails. Return the total units to purchase.
- Spares are ten percent, rounded up — a single unit has to be available even for a tiny fleet.
- The answer is units plus the rounded-up spare count.
SparesForScale(units: 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 SparesForScale(int units) {
}
Worked examples
| Call | Result |
|---|---|
SparesForScale(100) | 110 |
SparesForScale(1) | 2 |
SparesForScale(0) | 0 |
SparesForScale(10) | 11 |
Hint
Ceiling of ten percent in integers is (units + 9) / 10.
Reference solution in C#
public int SparesForScale(int units) {
return units + (units + 9) / 10;
}