Number of pathways of length n in a grid?

108 Views Asked by At

Given a square grid and a point $A:(0,0)$ and another point $B:(n,m)$ (where $n$ and $m$ are both integers), what is the number of pathways ($k$) of length $l$ (a natural number) edges are there between $A$ and $B$?

I was experimenting with this on my own, without any sort of proof and found that, at least for a knight's jump, there are no paths of an even length. However, there are several for 3 and 5. So I started wondering if there is any function relating $l$, $n$, and $m$ to $k$?

1

There are 1 best solutions below

0
On

If you colour the grid points alternately black and white in a chequerboard fashion, then each move takes you from a black to a white point or vice versa. So a path of even length goes from a point to a point of the same colour. Then there can't be any paths of even length spanning a knight's move.

Let's count the paths of length $5$ spanning a knight's move, for definiteness' sake from $(0,0)$ to $(2,1)$. There must be either (i) three right steps, one left step and one up step, or (iii) two right steps, two up steps and one down step. The number of paths in each case is given by a multinomial coefficient, namely $\binom{5}{3,1,1}=20$ and $\binom{5}{2,2,1}=30$. So there are $50$ paths.

In general the number of paths can be expressed as a sum of multinomial coefficients (but I suspect not in a "closed" form).