Reputation: 171
In a rectangular grid of size m*n, the number of paths from (0,0) to (m,n) (without backtracking) is (m+n)!/(m!*n!). Now if there are certain points in the grid which we want to avoid, how can we calculate the number of paths avoiding those points?
Upvotes: 2
Views: 2645
Reputation: 101
A natural question here is to ask: for any given k, what is the maximum number of monotonic paths avoiding a set S of k points (where the maximum is over all possible sets S)?
This is actually an open problem raised in a paper of Johnson, Leader and Russell: http://arxiv.org/pdf/1309.4643.pdf
Upvotes: 0
Reputation: 45071
The (recursive) equations defining the solution are as follows:
Obviously, as Qnan stated, you need to use dynamic programming (i.e. memorize partial solutions to avoid exponential time) to solve these for (0,0).
Upvotes: 2
Reputation: 3744
I don't think there's a reasonable analytical solution for a grid with exactly k
points blocked, but one can count the paths using a dynamic programming algorithm.
An analytical solution is troublesome because the number of blocked paths will depend no only on the number of blocked nodes and position of each node, but also on their relative positions. E.g. in a 4x4 grid, these two configurations give very different results:
.... ....
..x. .xx.
.x.. ....
.... ....
It is easy to see that the former allows for only two monotonic paths, while the latter has at least 5.
Upvotes: 1