TurnAndMove(1,3) TurnAndMove(1,5) TurnAndMove(1,2)
Five mazes have been created for you. The code you write to escape each maze should be as simple, concise, and elegant as possible.
For example, this solution works for Maze 1:
But nesting one repeat
block inside another makes the code more concise and, most programmers would agree, more elegant:
The AP CSP Exam Reference Sheet uses a text based code for these blocks: MOVE_FORWARD(), ROTATE_RIGHT() and ROTATE_LEFT().
Robot
and the Board
sprites. For each of the given mazes, write the shortest and most elegant code to help the robot escape. Use only these four custom Motion blocks (along with whatever Control blocks you need):TurnAndMove
:PROCEDURE TurnAndMove (numberOfTurns, numberOfMoves) { REPEAT numberOfTurns TIMES { ROTATE_LEFT () } REPEAT numberOfMoves TIMES { MOVE_FORWARD () } }
TurnAndMove(1,3) TurnAndMove(1,5) TurnAndMove(1,2)
TurnAndMove(1,3) TurnAndMove(3,5) TurnAndMove(1,2)
TurnAndMove(3,1) TurnAndMove(5,3) TurnAndMove(2,1)
TurnAndMove(1,4) TurnAndMove(3,6) TurnAndMove(1,3)
Draw Your Maze
code in the Board sprite (shown below).Escape Your Maze
code for the robot.