This works but it's an extremely kludgy implementation, I wouldn't recommend beginners learn from this. What if the grid was 4x4 or 10x10, more coding cases? Hint: Use the min max algorithm or breadth first search for a better implementation. That's more advanced programming though.
|