Identifying Path In Matrix Game
I am returning the length of the shortest path if there's is one. Otherwise, I return -1. I'm trying to print the matrix in such a way that all visited nodes that were a part of th
Solution 1:
The issue is in how you address grid
:
When looking for the next available move, you do this test:
grid[y2][x2]!=0
where (x2, y2)
is potentially added to the path.
But when you finally assign the $
, you write:
grid[i][j] = '$'
where (i, j)
is the tuple taken from the path.
This is not consistent. You should swap the coordinate position in one of the two grid[][]
expressions to make them consistent.
Post a Comment for "Identifying Path In Matrix Game"