Created
December 4, 2020 18:57
-
-
Save iJustErikk/819ce85a160ee63c23953b04a6eaf1b5 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
const spaceTraveler = (x, y, z) => { | |
if (x === 0 || y === 0 || z === 0) return 0; | |
if (x === 1 && y === 1 && z === 1) return 1; | |
return spaceTraveler(x - 1, y, z) + spaceTraveler(x, y - 1, z) + spaceTraveler(x, y, z - 1); | |
}; | |
console.log(gridTraveler(4, 4, 4)); | |
// you are traveling in space | |
// you are at (0, 0, 0) | |
// find how many ways you can get to (x, y, z) by only increasing to them | |
// x,y,z > 0, are integers | |
// naive solution |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment