Your question is BFS Shortest Path to Call. 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.
Axon Dispatch represents a service area as a rectangular grid. An officer must reach an emergency call using the shortest route through traversable cells while avoiding blocked cells.
Implement shortest_path(grid, start, target) using Breadth-First Search. Return the shortest route as a list of coordinate pairs, including both start and target. If the target cannot be reached, return an empty list.
grid is a list of equal-length lists containing 0 for a traversable cell and 1 for a blocked cell.start and target are coordinate lists in the form [row, column].def shortest_path(grid, start, target):