[Math] Number of paths from A to B with no direction constraints

combinationscombinatoricsgraph theory

There's a fairly common problem finding paths which is usually stated something like this:

Consider a grid that is 4 rows by 4 columns with the
upper left corner named A and lower right corner named B.

Suppose that starting at point A you can go one step down or one step to
the right at each move. This is continued until the point B is
reached. How many different paths from A to B are possible?

This problem is very easy to solve. One Solution.

However, this problem becomes extraordinarily more difficult if we ignore the direction constraint:

you can go one step down or one step to the right at each move.

The only rule is that you cannot pass through the same cell twice.

Is it possible to determine the number of unique paths from A to B without simply trying every possible path?

Can we apply our solution to any n x n grid? What about any m x n grid?

(P.S. This is not a homework question. I came up with it a few hours ago and have been trying to solve it since.)

Best Answer

I believe this is the problem of counting self-avoiding rook walks, and for the square case, you can look here for the first few values at the OEIS here. Unfortunately it seems like there is no known closed-form expression for arbitrary $n$. There's some more information and references at Mathworld.