Unique Paths
Advanced
Unique Paths
Imagine you're exploring a magical grid world! The grid has m rows and n columns. Starting at the top-left corner (your home) and wanting to travel to the bottom-right corner (the finish), you can only move right or down in the grid.
Your task is to determine the number of unique paths (or different ways) you can take to reach from your home to the finish.
How it Works:
- Assume the grid doesn't contain any obstacles.
- You can only move right or down at any point in time.
- You'll need to write a function
unique_paths(m, n)that computes the total number of unique paths to get from the top-left to bottom-right.
Examples:
unique_paths(3, 7) # returns 28 unique_paths(2, 2) # returns 2 unique_paths(1, 10) # returns 1 unique_paths(5, 5) # returns 70
See if you can come up with an efficient way to calculate these paths!
Happy exploring this magical grid world!
Inputs
Arg 1:
3Arg 2:
7Expected Output
28Actual Output