# How can I find the number of the shortest paths between two points on a 2D lattice grid?

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.

-

1
– Jalaj Jan 29 '12 at 12:25

## 1 Answer

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

-

You need to assume that $m, n$ are non-negative here, but up to reflection this loses no generality. – Qiaochu Yuan Jan 29 '12 at 2:58
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 12, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": false}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "github"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "english_confidence": 0.9487433433532715, "perplexity_flag": "head"}