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.
spares_for_scale(units: int) → int
Where you start
def spares_for_scale(units: int) -> int:
Worked examples
| Call | Result |
|---|---|
spares_for_scale(100) | 110 |
spares_for_scale(1) | 2 |
spares_for_scale(0) | 0 |
spares_for_scale(10) | 11 |
Hint
Ceiling of ten percent in integers is (units + 9) / 10.
Reference solution in Python
def spares_for_scale(units: int) -> int:
return units + (units + 9) // 10