Write MazeBfs. Read rows cols and a maze: # wall, . free cell, S start, E exit. Moves go up, down, left or right. A grid is a graph whose vertices are the free cells, so run breadth-first search from S, storing in distance[r][c] the number of steps of the first visit (−1 = not reached).
Print the length of the shortest way out (or No way out), the number of cells reachable from S (S included) and the distance of the farthest reachable cell.
For the input
5 7
S.#....
.##.##.
....#E.
.##.#..
...#...
the program prints
Shortest way out: 13 steps
Cells reachable from S: 25
Farthest reachable cell: 16 steps away