Drill

ProblemsJavaScript › machines

Spares to keep for a fleet

easymachinesJavaScript

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

Solve it in the editor →

Where you start

function sparesForScale(units) {
  
}

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 JavaScript
function sparesForScale(units) {
  return units + Math.floor((units + 9) / 10);
}

The same problem in another language

More machines problems in JavaScript