Skip to content

Instantly share code, notes, and snippets.

@iJustErikk
Created December 4, 2020 18:57
Show Gist options
  • Save iJustErikk/819ce85a160ee63c23953b04a6eaf1b5 to your computer and use it in GitHub Desktop.
Save iJustErikk/819ce85a160ee63c23953b04a6eaf1b5 to your computer and use it in GitHub Desktop.
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