6

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.

Asaf Karagila
  • 405,794
Leo Jiang
  • 457
  • 1
    This question has been previously asked and resolved here http://math.stackexchange.com/questions/103480/number-of-ways-of-reaching-a-point-from-origin/103485#103485 – Jalaj Jan 29 '12 at 12:25

3 Answers3

15

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}$.

NKS
  • 4,490
0

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.

0

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$$

Joypal
  • 170