Steps through a maze

maze is a list of strings using S for the start, E for the exit, # for walls and . for open floor. Moves go up, down, left or right. Write maze_steps(maze) that returns the fewest moves from S to E, or -1 if the exit cannot be reached.

maze_steps(["S.#", ".##", "..E"])  ->  4
maze_steps(["S#E"])                ->  -1

The point is to practise BFS on a grid with a distance map.

def maze_steps(maze):
    ...