n=100;
pass=zeros(n,4*n+1);
for l=1:1:9
walk=load(strcat('bridges0', num2str(l)));
figure(l)
plot(walk(:,1),walk(:,2))
figure(1)


num_steps=size(walk,1);
height=walk(num_steps,2);
for i=1:1:n
    
    y=(height-.25)*i/n;
   for j=1:1:(4*n+1)
       
       x=((j-1)/n-2)*height;
        counter=0;
       for k=1:1:num_steps-1
        yo=walk(k,2);
        yone=walk(k+1,2);
        xo=walk(k,1);
        if yo>yone
            temp=yo;
            yo=yone;
            yone=temp;
        end
            if (yo<=y && y<yone && x<xo)
                counter=counter+1;
            end           
       end
        if mod(counter,2)==1
            pass(i,j)=pass(i,j)+1;
        end   
   end
end


hold on
plot(walk(:,1),walk(:,2))
end
x=[-2*height:height/n:2*height];
y=[height/n:height/n:height];
contour(x,y,pass)
passright=load('passright')
figure(2)
contour(x,y,passright)