Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yasinabdmahmood/number-of-paths
https://github.com/yasinabdmahmood/number-of-paths
Last synced: 13 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/yasinabdmahmood/number-of-paths
- Owner: yasinabdmahmood
- Created: 2022-11-15T19:16:35.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2022-11-15T19:19:53.000Z (about 2 years ago)
- Last Synced: 2023-03-06T13:13:36.968Z (over 1 year ago)
- Language: Ruby
- Size: 1.95 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Number of Paths
You’re testing a new driverless car that is located at the Southwest (bottom-left) corner of an n×n grid. The car is supposed to get to the opposite, Northeast (top-right), corner of the grid. Given n, the size of the grid’s axes, write a function numOfPathsToDest that returns the number of the possible paths the driverless car can take.
![image](https://user-images.githubusercontent.com/97350474/202006510-02095871-0891-4cd8-83fe-470096e5f03c.png)For convenience, let’s represent every square in the grid as a pair (i,j). The first coordinate in the pair denotes the east-to-west axis, and the second coordinate denotes the south-to-north axis. The initial state of the car is (0,0), and the destination is (n-1,n-1).
The car must abide by the following two rules: it cannot cross the diagonal border. In other words, in every step the position (i,j) needs to maintain i >= j. See the illustration above for n = 5. In every step, it may go one square North (up), or one square East (right), but not both. E.g. if the car is at (3,1), it may go to (3,2) or (4,1).