Last active
April 7, 2016 18:26
-
-
Save danielrsmith/a57f458c5beeda0ad9b3e26e690bf429 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
# 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