If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

Main content

Conditional repetition of instructions

AP.CSP: AAP‑2 (EU), AAP‑2.K (LO), AAP‑2.K.3 (EK), AAP‑2.K.4 (EK), AAP‑2.K.5 (EK)


MouseyBot is a programmable robot that can be programmed using the following procedures:
walkForward(numSpaces)Walks forward the given number of spaces in the grid.
turnLeft()Rotates left 90 degrees (without moving forward).
turnRight()Rotates right 90 degrees (without moving forward).
facingWall()Returns true if robot is facing a wall (in the space in front).
canTakeCheese()Returns true if robot is on a space with cheese.
MouseyBot is currently positioned inside a grid environment, facing left in the fifth row, fourth column. A wedge of DigiCheese is located in the second row, first column.
MouseyBot would like to reach the DigiCheese. Here's the start of a program that uses a loop to program his journey:
REPEAT UNTIL ( canTakeCheese() )
There are many ways for him to reach the cheese. Of the options below, which will require the least repetitions of the loop?
Choose 1 answer: