Skip to content

Instantly share code, notes, and snippets.

View yUtopist's full-sized avatar
😶‍🌫️
Developing

Aleksei Stukalov yUtopist

😶‍🌫️
Developing
  • Christchurch, New Zealand
View GitHub Profile
@yUtopist
yUtopist / largestRemainderRound.js
Last active March 27, 2021 12:40 — forked from scwood/largestRemainderRound.js
Largest remainder round
/**
* largestRemainderRound will round each number in an array to the nearest
* integer but make sure that the the sum of all the numbers still equals
* desiredTotal. Uses Largest Remainder Method. Returns numbers in order they
* came.
*
* @param {number[]} numbers - array of numbers
* @param {number} desiredTotal - denominator: 100 for %, 360 for deg
* @return {number[]} the list of rounded numbers
* @example