You are given a square grid with some cells open (.) and some blocked (X). Your playing piece can move along any row or column until it reaches the edge of the grid or a blocked cell. Given a grid, a start and a goal, determine the minmum number of moves to get to the goal.
The grid is shown below:
The starting position so start in the top left corner. The goal is . The path is . It takes moves to reach the goal.
Complete the minimumMoves function in the editor.
minimumMoves has the following parameter(s):
string grid[n]: an array of strings that represent the rows of the grid
int startX: starting X coordinate
int startY: starting Y coordinate
int goalX: ending X coordinate
int goalY: ending Y coordinate
int: the minimum moves to reach the goal
The first line contains an integer , the size of the array grid.
Each of the next lines contains a string of length .
The last line contains four space-separated integers,