**An** express riddle from the Riddler about reopening pools, where lanes are allowed provided there is no swimmer in the lane or in any of the adjacent lanes. If swimmers pick their lane at random (while they can), what is the average number of occupied lanes?

If there are n lanes and E(n) is the expected number of swimmers, E(n) satisfies a recurrence relation determined by the location of the first swimmer:

with E(0)=0, E(1)=E(2)=1. The above can be checked with a quick R experiment:

en=0
for(t in 1:T){
la=rep(u<-0,N)
while(sum(la)<N){
i=sample(rep((1:N)[!la],2),1)
la[max(1,i-1):min(N,i+1)]=1
u=u+1}
en=en+u}

### Like this:

Like Loading...