6
$\begingroup$

How do you find the number of the shortest distances between two points on a grid where you can only move one unit up, down, left, or right? Is there a formula for this?

Eg. The shortest path between $(0,0)$ and $(1,1)$ can be $(0,0)\to (0,1)\to (1,1)$ or $(0,0)\to(1,0)\to(1,1)$, so there are two shortest paths.

$\endgroup$
1

3 Answers 3

15
$\begingroup$

Any shortest path from $(0,0)$ to $(m,n)$ includes $m$ steps in the x axis and $n$ steps in the y axis; what governs the shape of such a path is the order in which we choose to go to the right and up. Since we have $m+n$ total steps to take, we just need to choose which $m$ will be to the right. This is counted by the binomial coefficient $\binom{m+n}{m} = \binom{m+n}{n}$.

$\endgroup$
1
  • $\begingroup$ You need to assume that $m, n$ are non-negative here, but up to reflection this loses no generality. $\endgroup$ Commented Jan 29, 2012 at 2:58
0
$\begingroup$

I know I’m very late, but this is more for others than the original asker.

The number of shortest paths between (X1,Y1) and (X2,Y2) can is:

$\frac{(|X1-X2|+|Y1-Y2|)!}{(|X1-X2|!)(|Y1-Y2|!)}$

Probably.

It works for every scenario that I’ve tested so far, but it might be wrong because I haven’t put in the effort to check every single potential path of farther separated points.

Really sorry if this doesn’t work, I’m kind of an amateur mathematician.

$\endgroup$
1
  • $\begingroup$ This works for negative and positive numbers $\endgroup$ Commented May 27, 2022 at 23:43
0
$\begingroup$

OK! I see that the answers given earlier are quite straight forward, but since I came across this question. I want to put my 2 cents in this.

lets say, you have to give from point $A(0,0)$ to point $B(4,4)$ as shown in the figure.

enter image description here

You have to take total 8 steps, out of which 4 steps are to the right and 4 steps are up. If we donate a step to the right by R and a step up by, the required answer is equal to the number of ways in which we can arrange 4 Rs and 4 Us.

$$\therefore Required \space number of ways= \frac{8!}{4!\dot4!} = \frac {5 \times 6\times 7\times 8}{4\times 3\times 2\times 1}=70$$

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .