Last active
July 26, 2021 13:44
-
-
Save shayarnett/832a0b44dd2225d69a643243a7782c52 to your computer and use it in GitHub Desktop.
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
class Integer | |
def fact | |
downto(1).inject(:*) || 1 | |
end | |
end | |
def escape_routes(streets, avenues) | |
blocks = streets + avenues | |
blocks.fact/streets.fact/avenues.fact | |
end | |
puts escape_routes(2,2) #=> 6 | |
puts escape_routes(10,10) #=> 184756 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment