A loom threads a shuttle across a rectangular field of pins arranged in R rows and C columns. The shuttle starts at the top-left pin and must arrive at the bottom-right pin. On every move it advances to the pin one place to the right, or the pin one place below its current pin. It never moves left, up, or diagonally.
Count how many distinct threading routes reach the bottom-right pin.
A single line with two integers R and C, separated by a space.
A single integer: the number of distinct right/down routes from the top-left pin to the bottom-right pin.
Example 1
Input
3 3
Expected
6
Explanation
In a 3x3 pin grid the shuttle makes 2 right and 2 down moves in some order; there are 6 distinct orderings, so 6 routes.
Example 2
Input
1 5
Expected
1
Explanation
A single row of 5 pins forces the shuttle to move right every time, so there is exactly 1 route.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →