Lattice paths - Project Euler

283 Views Asked by At

Problem 15 asks that how many routes there are through a $20×20$ grid(starting from upper left corner) only being able to move to the right and down. My answer is wrong. And i would like to know what is wrong with my approach.

Now lets consider 2x2 grid and let the starting point be $(2,2)$. We want to reach $(0,0)$. One of the way is $$(2,2)\mapsto(2,1)\mapsto(2,0)\mapsto(1,0)\mapsto(0,0)$$

As we can observe we subtract $1$ at a time. What makes a path to be unique is the order of the subtractions.
$$(2,2)\mapsto(2,1)\mapsto(2,0)\mapsto(1,0)\mapsto(0,0)$$ $$right\mapsto right\mapsto left \mapsto left$$

Since we are dealing with $(2,2)$ as soon as we have $2$left and $2$ right we arrive to the end point.

We have 2 options: L (left) and R (right). So in order to find unique paths we have to arrange LLRR as much as possible without duplicates which is $C(4,2)$.

So by same logic my answer to the question is $C(40,20)$ = $137,846,528,820$ which is wrong.

Thank you.

1

There are 1 best solutions below

1
On

137846528820 should be correct. Maybe you are entering the number with commas or something?