Drill

ProblemsGo › machines

Spares to keep for a fleet

easymachinesMathGo

To scale a fleet safely, buying 10% extra units as spares keeps the line alive while one fails. Return the total units to purchase.

sparesForScale(units: int) → int

Go 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

func sparesForScale(units int) int {
	
}

Worked examples

CallResult
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 Go
func sparesForScale(units int) int {
	return units + (units + 9) / 10
}

The same problem in another language

More machines problems in Go