Write a (separate) program that takes a random walk on an NxN grid. The walker should do the following:
- Walk on a 10x10 grid
- Start at the position 5, 5
- Never move to a position it has occupied previously
- Never move off the grid
- Determine the set of legal moves from the current position. Legal moves are one space, either up, down, right or left AND that do not violate either of the preceding conditions.
- Choose a move to make randomly from among the legal moves.
- Print each move made on a single line. This may be as simple as "23 [3,2]" which would mean that on move 23 the walker was in position 3,2
- Return the number of steps it takes before the walker gets to a point of having no legal moves.
For instance, suppose that the sequence of moves is (s int he table indicates start, you could use 0 instead):
s [5,5]
1 [6,5]
2 [7,5]
3 [7,6]
4 [7,7]
5 [6,7]
6 [5,7]
7 [5,6]
8 [6,6]
Then at this point there are no remaining legal moves since the walker has already been to every position possible from [6,6]. Hence, program (or function) should return 8. In fact 8 moves is the shortest walk possible (on a 10x10 board) given the rules above.