Unlimited power!

Report a typo

C-3PO is a robot who lives in a square maze, as shown in the picture. C-3PO can move up, down, left, and right; and its movement is restricted by the walls (the bold lines in the maze).

Square maze

As we know, C-3PO is controlled algorithmically, hence, we give to it the following algorithm:

WHILE right is free

    go right 

WHILE wall is in the right and bottom is free

    go down

IF ROBOT is in cell F6 

    stop

Starting from cell A1, does C-3PO reach the orange box F6 after performing the algorithm? If yes, write the number of cells visited by C-3PO. Otherwise, write -1. Note that the first and the last cells also count.

Also consider that "right" and "left" in the program are in relation to how you see the map. The robot has no direction.

Enter a number
___

Create a free account to access the full topic