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

Problem

MouseyBot is a programmable robot that can be programmed using the following procedures:
NameDescription
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() )
{
    <MISSING CODE>
}
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:
🤔
Stuck?
Stuck?