2
$\begingroup$

Possible Duplicate:
Counting number of moves on a grid

I have an exercise in my Computer Science class, to figure out how many paths there are from $(0,0)$ to $(x,y)$ on a cartesian coordinate system, while the only legal moves are move up and move right.

Is there a simple method to calculate the number of available paths?

  • 1
    This is very similar to PE 15 (FYI)... http://projecteuler.net/problem=152012-12-07

2 Answers 2

3

Yes, there is. You must go right $x$ times and up $y$ times, and you may make these $x+y$ moves in any order. Write R for a right move and U for an up move: you want the number of strings of $x$ R’s and $y$ U’s. There are $\binom{x+y}x$ ways to choose which $x$ places get the R’s, and that completely determines the string, so the answer is $\binom{x+y}x$.

2

Assuming $x\ge 0$ and $y\ge 0$ you will make $x+y$ moves in total and among these are $y$ moves up. That should be $x+y\choose y$.

  • 0
    @amWhy Of course, thanks2012-12-07