Solution to the grid walk problem.