Paths around walls

Write code · Medium · §10.3 Two-dimensional grid tables

The map of a live-stream mini game is a grid. grid[i] is row i from the top, and grid[i][j] is cell j from the left in that row. If it is ".", you can pass through that cell, and if it is "#", the cell is a wall that you cannot pass through. Rows and columns are numbered from 0.

The character starts at the top-left cell and moves one cell at a time, only right or down, until it reaches the bottom-right cell. Complete the function solution, which returns the number of paths it can take. Two paths are different if at least one cell they pass through is different. If the starting cell or the goal cell is a wall, or there is no path at all, return 0. If the map has only one cell and it is not a wall, there is one path that does not move.

Function

solution(grid)

Constraints

Examples

gridresult
['...', '..#', '...']3
['....', '...#', '.#..', '....']7

Starter code

def solution(grid):
    answer = 0
    return answer

Solve this problem in your browser

Python runs in your browser and checks your answer right away. Hints and the answer are on the problem page.