The snake and the ladder 2

In a game of a snake and a ladder, the snake is to move exactly 35 steps. If the number of steps the snake takes at any point up the ladder is determined by a fair six-sided die such that if the number shown on the die is n n , the snake takes n n steps up the ladder.

In how many ways can the snake reach its destination?

Inspired by The snake and a ladder .

Image Credit: Wikimedia Druyts.t .


The answer is 13435170943.

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

Daniel Branscombe
Aug 17, 2015

using generating functions it is a simple one-liner in Mathematica

1
2
Coefficient[
 Expand[Sum[(x + x^2 + x^3 + x^4 + x^5 + x^6)^t, {t, 1, 35}]], x^35]

To break it down, after t throws of the die, the number of ways of arriving at step n is given by the expansion of (x+x^2+x^3+x^4+x^5+x^6)^t

After 35 moves he is going to be on or past step step 35, then we need to sum the above for t=1 to 35. After that we simply find the coefficient of x^35.

Abdelhamid Saadi
Aug 19, 2015

let f ( m ) f(m) be the number of ways for the snake to reach m m steps.

We can see that : f ( m + 6 ) = f ( m + 5 ) + f ( m + 4 ) + f ( m + 3 ) + f ( m + 2 ) + f ( m + 1 ) + f ( m ) f(m+6) = f(m+5) + f(m+4) + f(m+3) + f(m+2) + f(m+1) + f(m)

Here is a solution in python 3.4:

1
2
3
4
5
6
7
8
def solve(n):
    " The snake and the ladder 2 "
    fm = [1]
    for i in range(n):
        fm.append(sum(fm[-6:]))
    return fm[n]

print(solve(35))

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...