Finding Number of ways to a location. I have come across this question recently and cant find an answer but instead have come up with a number of answers. Please tell me what answer you get.
A __ __ __ __
 |__|__|__|__|
 |__|     |__|
 |__|__ __|__|
 |__|__|__|__|
              B

In how many ways is it possible to travel from A to B (following the lines) if you can only travel right or downwards. 
I'm not sure but I think 38 is the answer.
Thanks in advance, Monacraft.
 A: Here’s a systematic way to count the paths in a small problem like this one. The array below shows the intersections in your diagram as dots ($\bullet$), except that the corner intersections are shown with their labels instead; the non-existent intersection is shown as $\oplus$. 
$$\begin{array}{ccc}
A&\bullet&\bullet&\bullet&\bullet\\
\bullet&\bullet&\bullet&\bullet&\bullet\\
\bullet&\bullet&\oplus&\bullet&\bullet\\
\bullet&\bullet&\bullet&\bullet&\bullet\\
\bullet&\bullet&\bullet&\bullet&B
\end{array}$$
The idea is to work from upper left to lower right, replacing each dot or letter by the number of paths from $A$ to that dot. The key insight is that you can reach a dot in one step only from the dot immediately above (if any) and the dot immediately to the left (if any). Thus, if the dot immediately above can be reached in $a$ ways from $A$, and the dot immediately to the left can be reached in $\ell$ ways, then the given dot can be reached in $a+\ell$ ways.
There is just one way to reach $A$: don’t move. Thus, we can replace the $A$ with a $1$. The dot immediately to the right of $A$ can be reached only from $A$, so there’s only one way to reach it. In fact, each dot in the top row can be reached from $A$ in only one way, and the same goes for the dots in the lefthand column. After filling in these values, we have the following array:
$$\begin{array}{ccc}
1&1&1&1&1\\
1&\color{red}\bullet&\bullet&\bullet&\bullet\\
1&\bullet&\oplus&\bullet&\bullet\\
1&\bullet&\bullet&\bullet&\bullet\\
1&\bullet&\bullet&\bullet&B
\end{array}$$
We now have enough information to replace the red dot with a number: it can be reached from the left and from above, so it can be reached from $A$ in $1+1=2$ ways. Once we have it, we see that the dot to its immediate right can be reached from $A$ in $2+1=3$ ways, and the dot immediately below it can be reached in $1+2=3$ ways. Continuing in this fashion, we fill in the remainder of the second row and second column:
$$\begin{array}{ccc}
1&1&1&1&1\\
1&2&3&4&5\\
1&3&\oplus&\color{red}\bullet&\bullet\\
1&4&\color{blue}\bullet&\bullet&\bullet\\
1&5&\bullet&\bullet&B
\end{array}$$
The red dot can be reached only from above, so it can be reached in $0+4=4$ ways. Similarly, the blue dot can be reached only from the left, so it can be reached in $4+0=4$ ways. Completing the rest of the array is straightforward, and we end with this:
$$\begin{array}{ccc}
1&1&1&1&1\\
1&2&3&4&5\\
1&3&\oplus&4&9\\
1&4&4&8&17\\
1&5&9&17&34
\end{array}$$
There are $34$ paths from $A$ to $B$.
A: I thinks matrix multiplication could be a general method for this kind of questions.


*

*Redefine your given road topology as a 24 node graph.


*Construct a $24\times24$ adjacent matrix $M$, A is node 1, and B is node 24.

*The city block distance (Loops are not allowed) from A to B is 8. Then the number of ways from A to B is equals to $a_{(1,24)}$ of $M^8$ [Reference].
The answer is 34 (verified by Matlab).
