For the first exercise, you’re not even
going to need a computer. Instead, you’re going to be simulating programming a
robot, and it’s a robot that can obey the following commands: It can pick up
one object and only one object. It can put down the object it’s currently
holding. It can turn clockwise 90 degrees or it can turn counterclockwise 90
degrees, and it can take one step forward. So these are the commands that are
available to the robot. The task that you’re going to have the
robot perform is to switch the position of these two books so that the one that
is on top ends up on the bottom and the one that was on the bottom ends up on
the top. The provisos are that, again, you can pick up only one object at a time. You can’t put anything on the floor, and the books have to be in the same
position on the table where they began. So if, when you’re done, they end up over
here or they end up over here, the task hasn’t been accomplished properly. The
robot starts facing the books standing right in front of them. This is a
solvable problem, and please don’t try and do this in your head. If you are
wondering how to start it, my suggestion is you take a couple of books and try
moving them around physically to get an idea of what the robot has to do. If
you’re stuck on where to begin, here’s something you might figure out: Well,
which commands can I do? I can’t take one step forward or I’ll fall over the table.
I could turn clockwise or I could turn counterclockwise but that’s not going to
help me any because I still haven’t gotten any closer to my goal, so it looks
like the only thing I can do to start moving closer to the goal is to pick up
the book. So that would be the first step in my program, so I’d write down the word
UP; and, by the way, you don’t have to write a whole phrase. You can make
them shorter, so instead of writing “pick up”, just write UP; DOWN. You can write this as CW, CCW, and STEP. So that’s the task. Give it a try; and
you’ll see the solution that I came up with in the next video. Don’t worry about
your solution being ultra-efficient or the shortest possible number of steps.
What you want to do is you want to make sure that the books are in this position
at the start and the top and bottom are reversed back where they started when
you’re done with the task–so go for it!