I suggest using a dynamic programming method to solve this problem. Each “unlocked” cell on the board will have a number associated with it, the number of ways to get to the lower right; this is currently an undefined number in each cell.
It is best to explain this with an example. Let's pretend that
OOOOOO
OXXOOO
OXXOOO
OOOOOO
OOOOOO
as our board, where X is an obstacle and O is the square into which we have not yet completed the number of paths in the lower right corner. Now we are working from the lower right corner back. We will start by filling in the number 1 in the lower right corner, although this may not make a general sense.
OOOOOO
OXXOOO
OXXOOO
OOOOOO
OOOOO1
Now the two squares closest to the lower right can be filled. They are light.
OOOOOO
OXXOOO
OXXOOO
OOOOO1
OOOO11
Now we can fill in 3 more squares:
OOOOOO
OXXOOO
OXXOO1
OOOO21
OOO111
In each case, what we do is simply add the number to the right of the square and the number below the square, where we assume that the zeros will be on the right and bottom sides of the board. The next step:
OOOOOO
OXXOO1
OXXO31
OOO321
Oo1111
So far, we have obtained binomial coefficients, what we expect in such a problem. The next step:
OOOOO1
OXXO41
OXX631
OO4321
O11111
More binomial coefficients. The next step:
OOOO51
OXXA41
OXX631
O54321
111111
I use the letter A for 10. This is like binomial coefficients, but we are missing a few tips. However, this will change soon. The next step:
OOOF51
OXXA41
OXX631
654321
111111
Notice the use of F for 15. Now everything is getting interesting. Since we cannot go through the obstacle, we map 0 to the cells in the obstacle. To fill the gap in the upper right corner, add F + 0 = F. Similarly, 0 + 6 = 6.
OOFF51
OXXA41
6XX631
654321
111111
The next step:
OFFF51
6XXA41
6XX631
654321
111111
Last step:
UFFF51
6XXA41
6XX631
654321
111111
Here I use U for 21 = F + 6. This is the answer to the question.
This procedure works in general. We can fill in any cell for which we know the numbers on the right and below, and gradually fill the entire rectangle.