A spider has its web in the shape of a regular hexagon. A fly is stuck to the web at a vertex that is diametrically opposite from the vertex at which the spider is. The spider can walk freely along the edges of the hexagon. At each vertex, it randomly chooses between walking on one of the two adjacent edges or staying at the vertex, all three choices with equal probability. If the time it takes to travel an edge is 5 seconds, while the waiting time at a vertex is 2 seconds, find the expected time it will take the spider to get to the fly?
Note: At the end of a waiting period at a vertex, a new random decision to stay at the vertex, or move along one of the two edges is made, with equal probability for the three choices.
I ran a simulation and got 45 sec. rather than Larry's 54. His series does indeed sum to 54.
I checked my sim, found a bug and fixed it. Cheers! Now I verify L's results.
Sim is below: power?
5
time per move, ave time 6.001 54.023
6
time per move, ave time 6.000 54.008
7
time per move, ave time 6.000 54.003
program flym
implicit none
integer iseed,ibig,j,pos,m,tottime,totmoves,i,k
real*8 t,tm
print*,'power?'
1 read*,j
if(j.eq.0)stop
iseed=time8()
call srand(iseed)
ibig=10**j
tottime=0
totmoves=0
do 2 i=1,ibig
pos=0
do k=1,1000
m=3*rand()
if(m.eq.0)then
totmoves=totmoves+1
pos=pos-1
tottime=tottime+5
if(pos.eq.-3)go to 2
elseif(m.eq.1)then
tottime=tottime+2
elseif(m.eq.2)then
totmoves=totmoves+1
pos=pos+1
tottime=tottime+5
if(pos.eq.3)go to 2
endif
enddo
print*,' more than 1000 moves! i,k ',i,k
stop
2 enddo
tm=(1.*tottime)/totmoves
t=(1.*tottime)/ibig
print*,'time per move, ave time ',tm,t
go to 1
end
Edited on September 12, 2019, 10:19 pm