Last active
April 7, 2016 19:48
-
-
Save chongkim/32c5d7e83a1f82b1d24371543bb04b6d to your computer and use it in GitHub Desktop.
find number of paths to a point on a grid
This file contains hidden or 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
def paths(x,y) | |
return 1 if x == 0 || y == 0 | |
paths(x-1,y) + paths(x,y-1) | |
end | |
# outputs: 184756 | |
puts paths(10,10) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment