Given is a grid with all squares on one diagonal being forbidden. You are allowed to start from any square, and move one step horizontally, vertically or diagonally. You are not allowed to visit a forbidden square or previously visited square. Your goal is to visit all non forbidden squares. Find, with proof, the minimum number of times you will have to move one step diagonally
Solution
1. Coloring the Grid:
- Color the cells of the grid in a checkerboard pattern, with alternating black and white cells. This means that any two adjacent cells (horizontally or vertically) will be of different colors, while any two diagonally adjacent cells will be of the same color.
2. Forbidden Diagonal:
- The main diagonal of the grid is forbidden. This means that for an grid, there are forbidden cells.
3. Counting Black and White Cells:
- Let be the number of white cells and be the number of black cells in the grid excluding the forbidden diagonal.
- For an even :
- The grid has an equal number of black and white cells, but the forbidden diagonal will have black cells and white cells.
- Thus, .
- For an odd :
- The grid will have one more cell of one color than the other. The forbidden diagonal will have black cells and white cells (or vice versa).
- Thus, and .
4. Difference in Number of Cells:
- Let be the positive difference between the number of white and black cells in the grid excluding the forbidden diagonal.
- For even , .
- For odd , .
5. Movement Constraints:
- In any horizontal or vertical move, the two cells will be of different colors.
- In any diagonal move, the two cells will be of the same color.
6. Balancing the Colors:
- To visit all non-forbidden cells, the total number of black and white cells lying on a horizontal or vertical segment of the path will be the same.
- Since there are extra white cells (assuming white cells are in excess), these cells will lie on some diagonal segment of the path.
7. Minimum Diagonal Moves:
- Therefore, there must be at least diagonal moves to balance the excess cells.
- For even , , so no diagonal moves are needed.
- For odd , , so at least diagonal moves are needed.
8. General Case:
- The minimum number of diagonal moves required is .
The final answer is .