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?

Brian's solution was enough to let me jump to the full solution.

Start with an n-cube, oriented so that its' 6 sides are top, bottom, left, right, front and back.

Step 1: Paint all if its 6 n-squared exposed sides using color 1.

Step 2:

Then, move the leftmost n-squared cubes to the right.

Then, move the front n-squared cubes to the back.

Then, move the bottom n-squared cubes to the top.

All of the painted sides are now out of the way, and all of the exposed
sides are now unpainted. Paint them all color 2.

Repeat process n-2 more times.

The resulting blocks now have all of their sides painted.

If you wish, repeat step 2 (without paint) as often as desired to cycle through any of the solidly colored n-cubes.