Skip to content

Instantly share code, notes, and snippets.

@danielrsmith
Last active April 7, 2016 18:26
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 danielrsmith/a57f458c5beeda0ad9b3e26e690bf429 to your computer and use it in GitHub Desktop.
Save danielrsmith/a57f458c5beeda0ad9b3e26e690bf429 to your computer and use it in GitHub Desktop.
# There will be 2n moves (or 20 in this case). However we only care about one directional unit (down or right).
# So if you think about 2n moves numbered 1 though 2n (or 1 - 20)
# The number of possible paths can be represented by the number of combinations of
# n of those numbers. So for 20 numbers, how many combinations of 10 of those numbers can you make.
def snake_case(n)
(1..2*n).to_a.combination(n).count
end
snake_case 10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment