You want to make up a set of 27 1-cm cubes with their faces variously colored red, yellow and blue. You want to do this in such a way that you can form any of three 3-cm cubes: one that is all red on the outside, one that is all yellow on the outside or one that is all blue on the outside. You can't repaint the original 27 cubes again--the same set of colorations for the 1-cm cubes must work regardless of whether you want the outside to be red, yellow or blue. How must you color the faces of the 27 1-cm cubes?

Then consider the same problem with 64 1-cm cubes using four colors this time, fitting together to make any one of four 4-cm solid-color-on-the-outside cubes.

Is there a method that will work for n^3 unit cubes with n colors?

For any sized large block, made up of "n" blocks per side, there are n³
blocks total. Each block has 6 faces so the total number of faces
availabel for painting is 6*n³.

Each face of the larger block contains n² smaller block faces, meaning
that the block as a whole has 6*n² faces painted. If n colors are
used, the total number of required painted faces is 6*n³.

This means that, for any sized block, each face must be used (there can
be no wasted faces) when constructing the block out of its particular
color, but this doesn't require/permit/forbid the actual
constructability; it simply indicates that a solution is combinatorily
not eliminated.