# Can Computers Think?Introduction to Computer Science

## CSC 106Union CollegeWinter 2010

### Homework exercise to prepare for class on Friday, 1/8

#### Purpose:

• to practice using conditionals and loops
• to practice working with rur-ple

#### Getting started

Here are some of the examples you have worked with in class:

#### Exercise 1: fix holes

The robot is on a street with a lot of holes. It is supposed to fix the holes by placing beepers over them.

Write a program that makes the robot move along the street and put a beeper down every time it finds a hole.

Just to recap, here is a list of the conditions that the robot can use:

• on_beeper()
• front_is_clear()
• right_is_clear()
• left_is_clear()
• facing_north()
• carries_beepers()

The world file is week1_fr_holes.wld. The robot carries more thanenough beepers to accomplish his task.

Save your program to a file called "week1_fr_holes.rur".

#### Exercise 2: close windows

This exercise is due to André Roberge.

Give this exercise a try. Don't worry, if you can't get it exactly right.

It was a beautifully sunny day. The robot was playing outside with his friend. Suddenly, it started to rain and the robot remembered that the windows in his house were all open. So he went back to his house and stopped in front of the door, unsure of how to proceed.

Help the robot close the windows of his house. A closed window, in the robot's world, has a beeper in front of it. When the robot finishes his task, he will stand in the doorway, watching the rain fall, waiting for it to stop before he can go back and play outside, as illustrated below.

The world file is week1_fr_windows.wld. The robot carries more thanenough beepers to accomplish his task.

Save your program to a file called "week1_fr_windows.rur".

#### Submit your solutions on Blackboard

Submit your two .rur files on Blackboard (online.union.edu).

You do not need to print anything out for this exercise.