I went back in an old Flash game and was intrigued by this problem.
Rules
- There is an $n\times n$ grid and a mouse entering on the entrance cell and exiting on the exit cell.
- The entrance cell and the exit cell is found outside on the grid, on the top and bottom side respectively. You can move them around.
- You can build any number of walls in the grid, as long as it does not block the exit cell.
When the walls are built, the mouse will be released.
The mouse moves as follows:
- The mouse moves one step towards one of the four cardinal directions: south, west, east, north.
- The mouse moves to the square it has visited the least.
- When there is a tie, the mouse prefers the order: down, right, left, up.
Here is an example animation on a $4\times 4$ grid: (Note that this is not the optimal solution, and you can use other $n\times n$ sized grids as well)
Questions:
- What is the maximum number of steps the mouse can have on a $n\times n$ grid?
- What is the maximum number of visits on the same cell can you have on a $n\times n$ grid?