Loading...
Loading...
Loading...
A floor has R rows and C columns of tiles. Some tiles are blocked, shown as #, and the free ones as a dot. A cart starts at the top-left tile and must reach the bottom-right tile, moving only right or down through free tiles. Print the number of routes.
Example 1
Input
3 3 ... .#. ...
Output
2
Only the route around the left and bottom, and the route around the top and right.
Example 2
Input
2 2 .# #.
Output
0
Try the problem first. Open one hint at a time.
A blocked tile has zero routes. A free tile adds the routes of the tile above and the tile to its left.
You can keep a single row of counts and update it row by row.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor