Your question is Shortest Path on a 2D Grid. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
An Amazon Robotics warehouse is represented as a rectangular grid. A cell with value 0 is traversable, and a cell with value 1 is blocked. Write a function that returns a shortest path from start to end, moving only up, down, left, or right.
Return the path as a list of [row, column] coordinates, including both endpoints. If no path exists, return an empty list. Any shortest path is acceptable.
Input consists of a binary 2D list grid, a starting coordinate start, and a destination coordinate end. The function returns a list of coordinate lists. The start and destination cells are guaranteed to be traversable.
def shortest_path(grid, start, end):