Ocado Robot Debugging Challenge!
Last updated
Was this helpful?
Last updated
Was this helpful?
Oh no! The program of an Ocado bot has a bug! This robot is supposed to collect the groceries, but it's not working correctly. Your mission is to debug the Python code and get the robot back on track.
The Grid:
Imagine the maze as a simple grid. Your robot can move in four directions: "up", "down", "left", and "right".
Here's the layout of your grid:
# represents a wall โ the robot can't go there.
- represents an empty space the robot can move through.
S is the robot's starting position.
A is the avocado.
B is the banana.
C is the carrot.
E is the delivery exit.
Identify the errors in the code.
Correct the errors so the robot can successfully collect the avocado ('A'), banana ('B'), and carrot ('C').
The robot should start at 'S' and end at 'E'
Here's the buggy Python code:
Debugging Tips:
Read the code carefully, line by line.
Think about the robot's starting position and the grid layout.
Trace the robot's movements based on the code.
Identify where the robot goes wrong.
Correct the code to ensure the robot reaches each item.
Test your corrected code to make sure it works!