Skip to content

Instantly share code, notes, and snippets.

Created September 11, 2015 11:06
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 anonymous/30816517dffe93ae9537 to your computer and use it in GitHub Desktop.
Save anonymous/30816517dffe93ae9537 to your computer and use it in GitHub Desktop.
Rabbit jumps upstairs.
N - number of steps that rabbit can jump at one time
X - total steps in stairs
N >= 1
X <= 300
N <= X
======
if x == 6 and n == 3
there will be 14 unique routes.
what if x == 17 and n == 5 ? :)
1 + 1 + 1 + 1 + 1 + 1
2 + 1 + 1 + 1 + 1
1 + 2 + 1 + 1 + 1
1 + 1 + 2 + 1 +1
1 + 1 + 1 + 2 + 1
1 + 1 + 1 + 1 + 2
3 + 1 + 1 + 1
1 + 3 + 1 + 1
1 + 1 + 3 + 1
1 + 1 + 1 + 3
3 + 2 + 1
2 + 3 + 1
1 + 2 + 3
1 + 3 + 1
3 + 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment