Coloring the faces of n^3 unit cubes s.t., for each color j between 1 and n, the cubes can be arranged to form nxnxn cube with j-colored outer faces

coloringcombinatoricspuzzlerecreational-mathematics

I encountered the following problem in Paul Zeitz's The Art and Craft of Problem Solving (problem 2.4.16 on page 56 of third edition):

Is it possible to color the faces of 27 identical $1 \times 1 \times 1$ cubes, using the colors red, white, and blue, so that one can arrange them to form a $3 \times 3 \times 3$ cube with all exterior faces red; and then rearrange them to form a $3 \times 3 \times 3$ cube with all exterior faces blue; and finally, rearrange them to form a $3 \times 3 \times 3$ cube with all exterior faces white? What about the general case ($n$ colors and an $n \times n \times n$ cube)?

I was able to come up with, through logical trial-and-error, the coloring that works for $n=3$, so I think the answer is 'yes'. Indeed, I verified my answer, as there is another post on this site concerning the $n=3$ case.

Unfortunately, I am extremely stuck on how to generalize this to the $n$ color case. Any hints or advice would be greatly appreciated. Thank you!

Best Answer

Here is a solution which does not require case-splitting based on $n$. This solution is an adaptation of Jaap's clever solution to the $3\times 3\times 3$ problem to the $n\times n\times n$ version.

Start with $n^3$ uncolored cubes. Label each cube with a distinct ordered triple, $(x,y,z)$, where $x,y,z\in \{0,1,\dots,n-1\}$. For the cube with label $(x,y,z)$,

  • color the top face with color number $x$, and the bottom face with color number $x+1$, where addition is modulo $n$,

  • color the left face with color number $y$, and the right face with color number $y+1$,

  • color the front face with color number $z$, and the back face with color number $z+1$.

Equivalently, the process can be described as follows.

  • Arrange the $n^3$ uncolored cubes into a big cube, and paint all outside faces the first color.

  • Take the top layer, and move it to the bottom, without rotating.
    Take the leftmost layer, and move it to the right, without rotating.
    Take the frontmost layer, and move it to the back, without rotating.
    Now, all outside faces are uncolored. Paint all outside faces with the next unused color.

  • Repeat the previous bullet $n-2$ times.

The latter description has the benefit of describing how to arrange all the little cubes into a cube so that the outside is monochrome in each of the $n$ colors.