Rocky Paths (Grids)

A robot starts at the top-left cell of a grid and must reach the bottom-right cell, moving only right or down. Cells marked 1 are rocks it cannot enter. Print how many different paths there are.

Input: r c (1 to 16 each), then r lines of c values, each 0 (free) or 1 (rock).

Output: The number of paths (0 if the start or the end is a rock).

Difficulty: Medium. Write your answer in the browser editor, run the examples, then submit it against hidden tests. Python and JavaScript are free; other languages are part of licode Club.

Hint

  • Paths into a free cell = paths into the cell above + paths into the cell to its left.

More Grids practice