Routes to Coffee Machine
Description:
You are an undergrad at Carnegie Mellon University, and you like coffee a lot.
However, navigating to the coffee machine is no trivial task. After getting lost in the building several times, you decide to draw a map of the current floor to aid your coffee retrieval.
An example map looks like this:
+ - - + - - + - - +
| | | |
+ - - + - - + - - +
| | | |
+ - - + - - + - - +
Each line represents a corridor (or pathway), and +
represents an intersection.
You are currently at the top-left intersection, while the coffee machine is located at the most bottom-right intersection. Assuming that you can only go down
or right
, figure out how many possible routes there are to the coffee machine.
Input
width
and height
width
and height
each specifies the amount of corridor intersections on that axis. In the example provided above, width = 4
and height = 3
.
As another example, a map of width = 3
and height = 2
looks like:
+ - - + - - +
| | |
+ - - + - - +
Output
Your function should return the total possible routes from your position (top-left) to the coffee machine (bottom-right) while only going down
or right
.
Consider this minimal example of width = 2
and height = 2
:
+ - - +
| |
+ - - +
You can either go ['right', 'down']
or ['down', 'right']
, therefore there are 2 possible routes.
Good luck!
Similar Kata:
Stats:
Created | Sep 18, 2020 |
Warriors Trained | 14 |
Total Skips | 0 |
Total Code Submissions | 34 |
Total Times Completed | 11 |
Python Completions | 9 |
Java Completions | 3 |
Total Stars | 0 |
% of votes with a positive feedback rating | 42% of 6 |
Total "Very Satisfied" Votes | 2 |
Total "Somewhat Satisfied" Votes | 1 |
Total "Not Satisfied" Votes | 3 |
Total Rank Assessments | 6 |
Average Assessed Rank | 7 kyu |
Highest Assessed Rank | 6 kyu |
Lowest Assessed Rank | 8 kyu |