Ok, I think this is the situation:
a b c d e
w[ ][ ][P][ ][ ]w
the pirate is at P (square c) and moves left or right, randomly, one square at a time. If he ever steps into the water, that's the end, and we want to know what is the expected number of steps before he lands in the water.
If this is correct, let E(x) be the expected number of steps that the pirate will take from square x. For brevity, I will let A = E(a), B = E(b) etc.
Further, by symmetry, A = E and B = D.
Now, suppose the pirate is at square A. He has 50-50 chance of going to the right, or to his death. Either way, we can calculate the expected number of steps from A in terms of the expected number of steps from B:
So A = 1/2(1) + 1/2(B+1). Or
A = 1 + B/2.
Similarly, B = A/2 + C/2 + 1 and C = B/2 + D/2 + 1 = B + 1.
So we have three equations:
A = 1 + B/2
B = A/2 + C/2 + 1
C = B + 1.
Substituting for A and C into equation 2 gives:
B = (1+B/2)/2 + (B+1)/2 + 1
B = 1/2 + B/4 + B/2 + 1/2 + 1
B = 2 + 3B/4
B/4 = 2
B = 8.
C = B + 1 = 9.
Since the pirate is at C, we can expect him to take 9 steps before he falls into the water.
____________________________
Progress Quest Progress