Climbing The Staircase

How many paths are there from A to B that only move up or right?


The answer is 132.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

2 solutions

Chung Kevin
Sep 30, 2016

For such problems, there is always the trivial approach of listing out the number of ways to reach each vertex, by proceeding form the start point and moving right / up. This may be tedious, but it works everytime.


There is actually a pattern to this staircase. Can you find the generalized answer?

With n n "nodes" along the base and right side, the number of paths is the Catalan number

C ( n ) = ( 2 n ) ! n ! ( n + 1 ) ! C(n) = \dfrac{(2n)!}{n!(n + 1)!} .

In this case there are C ( 6 ) = 12 ! 6 ! 7 ! = 132 C(6) = \dfrac{12!}{6!7!} = 132 pathes.

Brian Charlesworth - 4 years, 8 months ago

Log in to reply

Yes! How can we immediately relate it to the catalan numbers ?

Chung Kevin - 4 years, 8 months ago

@Chung Kevin The Catalan number is directly involved because one cannot go up without having gone right.

Yugesh Kothari - 4 years, 8 months ago

It must be 1 instead of 2 at 3rd bottom place from left.

Archit Agrawal - 4 years, 8 months ago

Log in to reply

It must be 1 in bottom row everywhere.

Archit Agrawal - 4 years, 8 months ago

Log in to reply

Oops. I have changed the image.

Chung Kevin - 4 years, 8 months ago
Pratik Shastri
Oct 9, 2016

A simple but time taking recursion -

def P(i, j):
    if i == 0 or j == 0: return 1
    else:
        if(j <= i): return (P(i - 1, j) + P(i, j - 1))
        else: return P(i, j - 1)

Here P ( i , j ) P(i, j) is the number of valid paths from ( 0 , 0 ) (0, 0) to ( i , j ) (i, j) .

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...