Task 4: Searching cloverleafs in a forrest I

Kara searches a cloverleaf. He knows there is one straight ahead - he only has to walk around the trees. Fortunately, there are never two trees next to each other. Write a program which leads him to the cloverleaf!

 

Task 5: Searching cloverleafs in a forrest II

Extend your program from task 4 so that Kara can deal with several trees next to each other. Hint: The solution to this task requires two states. Why is a single state not enough?

 

Task 6: Searching cloverleafs in a forrest III

Within Karas world there exist forrests with circuit tours in which Kara wants to go search for a cloverleaf. Every field in a circuit tour has exactely two empty neighbouring fields. One of them is behind Kara, the field Kara came from. That is, exactly one of the three question marks in the following image represents an empty field. The other two represent fields with trees: