Ayanna writes programs using the following commands that direct her robot to draw shapes.
| Command | Explanation |
|---|---|
Pencil down |
Puts the pencil in position to draw as the robot moves |
Move |
Moves the robot a given distance forward |
Turn CW |
Rotates the robot one quarter turn (\(90\degree\)) clockwise |
Turn CCW |
Rotates the robot one quarter turn (\(90\degree\)) counter clockwise |
For each program, follow the code to draw the shape. You may find grid paper helpful.
Pencil down
Repeat 4 times
Move 5 cm
Turn CW
End
Pencil down
Move 4 cm
Turn CCW
Move 2 cm
Turn CW
Move 2 cm
Turn CW
Move 6 cm
Turn CW
Move 6 cm
Turn CW
Move 4 cm
End
Write a program that would direct Ayanna’s robot to draw the given rectangular U-shape.
For each program, the shape is shown on \(1\) cm grid paper with an arrow indicating the initial direction of the robot. Note that for part (i), the shape will look the same regardless of the initial direction. However for part (ii), the shape will be rotated depending on the initial direction.
We start by determining the length of each side of the shape. We do this by drawing the shape on grid paper, as shown.
There are several different programs that can be written to direct Ayanna’s robot to draw the given shape, depending on the robot’s starting position and direction. In the following program, the robot starts in the bottom-left corner, facing to the right.
Pencil down
Move 10 cm
Turn CCW
Move 5 cm
Turn CCW
Move 2 cm
Turn CCW
Move 3 cm
Turn CW
Move 6 cm
Turn CW
Move 3 cm
Turn CCW
Move 2 cm
Turn CCW
Move 5 cm
End