Explorer Maze Escape


Collapse Content

The Java Explorer is back, but his sensors are broken! You'll need to help him find the path to the goal. Given a map of the area (as a square grid), can you help the Explorer find the way from position [0,0] to the goal? The explorer can go right or down within in the grid, and cannot go through walls.

I/O Format

Input
t for t test cases. Each test case consists of:
n for the size of the area
n*n square consisting of 0's, 1's and one 9.

0's mark empty space.
1's are walls.
9 is the goal

Output
Print the (shortest) path to the goal. Print each position [x, y] as shown below.

Sample Input

1
5
0 0 0 0 0
0 1 0 1 0
0 1 0 1 1
0 1 0 0 0
0 0 0 1 9

Sample Output

[0, 0]  [1, 0]  [2, 0]  [2, 1]  [2, 2]  [2, 3]  [3, 3]  [4, 3]  [4, 4] 

Explanation
Starting from [0,0] on the top left, the Explorer can reach the goal at [4,4] by following the printed path, as shown here:

→ →⤵0 0
0 1 ↓ 1 0
0 1 ↓ 1 1
0 1 ⤷ → ⤵
0 0 0 1 9

Challenge

Print the path to the goal!

Please sign in or sign up to submit answers.

Alternatively, you can try out Learneroo before signing up.

Comments

Contact Us
Sign in or email us at [email protected]