Skip to content

Instantly share code, notes, and snippets.

@chongkim
Last active April 7, 2016 19:48
Show Gist options
  • Save chongkim/32c5d7e83a1f82b1d24371543bb04b6d to your computer and use it in GitHub Desktop.
Save chongkim/32c5d7e83a1f82b1d24371543bb04b6d to your computer and use it in GitHub Desktop.
find number of paths to a point on a grid
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