Your question is Graph Shortest Path. 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.
A navigation system for a Rockstar game level represents a rectangular map as a grid. Find the shortest route from S, the starting position, to G, the goal, using only four-directional movement: up, down, left, and right. Cells marked # are blocked, while S, G, and . are walkable. Return every coordinate on the route, including both endpoints. If no route exists, return an empty list.
Implement shortest_path(grid), where grid is a non-empty list of equal-length strings. Return a list of [row, column] coordinate pairs in traversal order. The route may be any shortest route if multiple shortest routes exist.
def shortest_path(grid):