Task 1: Kara, the tunnel seeker I

Kara searches the entry of a tunnel (field 2a). Write a program which makes Kara stop on the first field inside the tunnel. Attention: some tunnels have at first only a wall on one side, some to the left, some to the right.

 

Task 2: Kara, the tunnel seeker II

Kara wants to find the exit of the tunnel (field 2b). Therefore, he first has to traverse the tunnel. Write a program which makes him stop on the first field behind the tunnel. He should not walk to the end of a one sided wall. Hint: The solution requires two states. Why can a single state ot be enough?