The snake and a ladder

In a game of a snake and a ladder, the snake is to move up the ladder of 35 steps. If the number of steps the snake takes 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.

What is the expected number of die-throws for the snake to reach its destination?


The answer is 10.47.

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.

1 solution

Brock Brown
Aug 17, 2015

Python 3.4:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
from random import randint
from time import time
def throws():
    count = 0
    position = 0
    while position < 35:
        position += randint(1, 6)
        count += 1
    return count
total_throws = 0
trials = 0
end = float(input("How long? (seconds) > ")) + time()
while time() < end:
    total_throws += throws()
    trials += 1
print ("Answer:", total_throws/trials)

this seems a little inaccurate. n should be exactly 10 since through linearity of expectation each dice roll gives you an expected increase of 3.5 steps, so 35/3.5 = 10... This converges to that, but will take some time

Jon Trollston - 2 years, 7 months ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...