Counting paths across a grid · Compiler
Counting paths across a grid
Count paths from the top-left cell to the bottom-right cell. Each move goes one cell right or down within the grid. Every visited cell must be open, including both endpoints. An open one-cell grid has one path of length zero.
- Input
- The first line contains r c (1 <= r,c <= 12). The next r lines are rows from top to bottom, each with c characters and no spaces. A dot is open and # is blocked.
- Output
- Print the exact number of paths, or 0 if no path exists.
Compiler Explorer runs your code when you run or check it.
Loading your exercise draft…