Draft

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!

Stats:

CreatedSep 18, 2020
Warriors Trained14
Total Skips0
Total Code Submissions34
Total Times Completed11
Python Completions9
Java Completions3
Total Stars0
% of votes with a positive feedback rating42% of 6
Total "Very Satisfied" Votes2
Total "Somewhat Satisfied" Votes1
Total "Not Satisfied" Votes3
Total Rank Assessments6
Average Assessed Rank
7 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • davidmaamoaix Avatar
Ad