Skip to content

Instantly share code, notes, and snippets.

@mjstromberg
Created October 13, 2019 23:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mjstromberg/da713c947127b5abe174b11eb7643f89 to your computer and use it in GitHub Desktop.
Save mjstromberg/da713c947127b5abe174b11eb7643f89 to your computer and use it in GitHub Desktop.
function getUniqueSteps(n, stepSizes = []) {
return stepSizes.reduce((sum, stepSize) => {
if (n < stepSize) {
return sum;
} else if (stepSize === n) {
return sum + 1;
} else {
return sum + getUniqueSteps(n - stepSize, stepSizes);
}
}, 0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment