Created
October 13, 2019 23:18
-
-
Save mjstromberg/da713c947127b5abe174b11eb7643f89 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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