An ant walks on a cube over the diagonals of little cubes. Can it visit all little faces exactly once?

Hint: can you see why the graph the ant is moving on is actually disconnected, with two components? Each facet is covered by two edges, but these edges are in different components. So the ant wants to cover all the edges of the component it is in.


Another explanation in the same vein as @Especially Lime placing in evidence an invariant.

This invariant is the parity of the sum of coordinates of the two endpoints of a given diagonal edge.

Case $n=1$ : Think to the cube as being $\{0,1\}^3$.

A diagonal path connects a vertex to another vertex by changing two coordinates (a change equivalent to a boolean complementation) ; this induces a partitionning of the 8 vertices into 2 classes of 4 that cannot be connected between themselves :

$$\begin{matrix}(0,0,0) \ \ &\|& \ \ (1,1,1)\\ (1,1,0) \ \ &\|& \ \ (0,0,1)\\ (0,1,1) \ \ &\|& \ \ (1,0,0)\\ (1,0,1) \ \ &\|& \ \ (0,1,0) \end{matrix}$$

This vertices' partitionning induces a partitionning of diagonals.

Another way to say this is that the left set has a parity-check (sum of coordinates) $0$ whereas it is $1$ for the second.

Case $n=2$ : This time, the vertices a subset of $\{0,1,2\}^3$ (we must take out interior point $(1,1,1)$). We have the same principle : if a diagonal in one face connects two points it means that

  • one coordinate remains fixed

  • the two others move by one unit.

Let us consider the cases where the coordinate with a fixed value is $z=z_0$ (with $z_0=0$ or $z_0=2$); the only possible "moves" are of type

$$(x,y,z_0) \leftrightarrow (x + e_1,y+e_2,z_0) \ \ \text{where} \ e_1,e_2=\pm1.$$

In all cases, the sum of coordinates of connected points either staies the same or is changed by $2$ units.

(same reasoning if the fixed coordinate is $y$ or $x$).

Therefore the $3^3-1=26$ vertices can be separated in the same way as for the case $n=1$ into two subsets that cannot "communicate", according to the parity of the sum of their coordinates. As a consequence, we have an induced partionning of the diagonal segments.

What we have done for these two cases extends immediately to the general case.

I am indebted to @Misha Lavrov who has spotted a default in my presentation.