LearnPy Hub
← Arena
IntermediateRating 1400

Escape the Maze

Find the fewest moves from S to E in a grid maze (# walls, . floor), moving up, down, left or right. Print -1 if impossible.

Input

r c, then r lines.

Output

A number.

Sample 1

Input
3 4
S..#
.#..
...E
Output
5

Sample 2

Input
2 2
S#
#E
Output
-1
solution.py
Output appears here
Escape the Maze · Python Arena problem · LearnPy Hub