Problem · Medium · 20 min
Climb the stairs
- Medium
- Dynamic programming
- Math
A stair has steps steps. You start at the bottom. With one move you climb 1, 2 or 3 steps. You want to reach the top exactly.
Write count_ways(steps). It returns the number of different sequences of moves that reach the top.
- The order of the moves matters.
1 + 2and2 + 1are two different ways. - For
stepsequal to 0, there is one way: make no move. stepsis a whole number from 0 to 40.
Examples
| Call | Result |
|---|---|
count_ways(3) |
4 |
count_ways(4) |
7 |
count_ways(0) |
1 |
Tasks
2 to do
Task 1, not checked yet. Make
count_wayspass the example tests.Task 2, not checked yet. Make
count_wayspass the hidden tests.
Task 1 of 2
Make count_ways pass the example tests.