Problem of the Week
Problem
B
Help
Send Freddy Home
Freddy the Robot starts in the top left square of the maze below,
facing left (symbolized by \(\leftarrow\)). Freddy wants to get to his
Home Charging Station in the bottom right corner of the maze, marked
with an H. Freddy can only turn right (clockwise on the
diagram), and will only turn the number of degrees which you tell him.
As well, he will go exactly the number of squares you tell him and in
the direction that the arrow is currently pointing.
For example, if he starts facing \(\leftarrow\), and your command said, "Turn
\(180\) degrees and go \(3\) spaces", he would turn \(180\degree\) right (clockwise) and then
move \(3\) spaces forward (to the
right).
Write a program of commands that gets Freddy to his Home Charging
Station.
The maze is constructed using a grid of squares with nine rows and ten columns. There is a path
through the maze consisting of connected white squares and the remaining
squares in the grid are black.
Starting at the top-left square (Row 1, Column 1) which is white and
has an arrow pointing left, the path of connected white squares is as
follows:
Right along Row 1 (top row) to Column 4.
Down along Column 4 to Row 3.
Left along Row 3 to Column 1.
Down along Column 1 to Row 6.
Right along Row 6 to Column 4.
Down along Column 4 to Row 9 (bottom row).
Right along Row 9 to Column 6.
Up along Column 6 to Row 1.
Right along Row 1 to Column 8.
Down along Column 8 to Row 2.
Right along Row 2 to Column 10 (rightmost column).
Down along Column 10 to Row 4.
Left along Row 4 from Column 10 to Column 8 and also left along
Row 5 from Column 10 to Column 8.
Down along Column 8 from Row 5 to Row 9 (bottom row).
Right along Row 9 to Column 10 (bottom-right square marked with
an H).