Problem:
A museum has a square floor plan and is divided into identical square rooms (with ). Every pair of adjacent rooms (i.e., sharing a common wall) communicates by means of a door (as shown in the example alongside for ). The night watchman wants to organize his inspection tour so as to respect the following rules: the watchman starts from a certain room, where he stays for one minute, at the end of which he moves to an adjacent room, where he stays for another minute; the path
continues connecting adjacent rooms, in each of which the watchman stays for exactly one minute before moving on.
It is allowed to pass through the same room more than once, but at the end of the path (which is not necessarily in the starting room) the watchman must have been in each of the rooms for exactly minutes.
Determine for which positive integers and it is possible to organize the path while respecting these rules.
Solution
Solution:
If is even, it is possible to construct the path for any . Indeed, one can exhibit a closed path that passes once through each room, and by making loops one obtains the watchman's journey.
Let us assume for convenience that the museum is oriented along the cardinal points. One way to construct this path is as follows: the watchman starts from the room in the south-west corner and proceeds along the south side until reaching the south-east corner.
At this point he still has to cross the rooms of an rectangle, which he traverses in a serpentine manner. He moves north for rooms (see example above for ), then he shifts west and goes back south for rooms. At this point he has crossed the two easternmost rows of rooms. If he shifts west and repeats the procedure, since is even, he crosses all the rows of rooms in pairs and can eventually return to the room from which he started.
If instead is odd, the problem has a solution only for . In this case it is easy to find the path, which however does not return to the starting point, by making a serpentine in the manner described above. To see that in the other cases there is no solution, let us think of coloring the rooms white and black, as on a chessboard, with black in the corners. It is easy to see that in this way the black rooms are one more than the white ones. Consequently, if the watchman could make a path that passes times through each room, he should have visited black rooms more than white ones. However he can
move from one room only to another of a different color, so the difference between black and white rooms visited can be at most 1 during the journey, and for there is no solution.