Color $27$ unit cube so that by rearranging, they could form a blue $3\times3$ cube, a green one, and a red one? I searched but there's not much useful information. My instinct is that it is not possible, but I don't know how to show it.
To make it clear, there are $27$ unit cubes, that is, $6\times27$ sides to be colored with blue, green, or red. Then you need to arrange them so that they form a $3\times3\times3$ cube, whose surfaces are blue. Then you rearrange unit cubes, so that they form a $3\times3\times3$ cube, whose surfaces are green. Then you rearrange them again, this time get a red $3\times3\times3$ cube.
More generally, can you color $n^3$ unit cubes with $n$ colors, so that after arraging, they can form $n$  $n\times n\times n$cubes, each cube's surfaces is in a different color?
When $n=1,2$, the answer is yes and the solution is obvious. But when $n$ is bigger, the problem seems complex, and I totally have no clue.
 A: For the $3 \times 3 \times 3$ case it is possible:

Haskell code:
{-# LANGUAGE FlexibleContexts #-}

import Diagrams.Prelude
import Diagrams.Backend.Cairo.CmdLine (defaultMain)

v x = [x,x,x]
e x = [x,x]
f x = [x]

cubes =
  [ v red ++ v green
  , v green ++ v blue
  , v blue ++ v red
  ]
  ++
  concatMap (replicate 6)
    [ v red ++ e green ++ f blue
    , v green ++ e blue ++ f red
    , v blue ++ e red ++ f green
    ]
  ++
  replicate 6 ( e red ++ e green ++ e blue )

draw [a,b,c,d,e,f] = pad 1.1 . centerXY $
  ((strutX 1 ||| square 1 # fc a)
  ===
  (square 1 # fc b ||| square 1 # fc c ||| square 1 # fc d ||| square 1 # fc e)
  ===
  (strutX 3 ||| square 1 # fc f))

chunk _ [] = []
chunk n xs = let (ys, zs) = splitAt n xs in ys : chunk n zs

diagram = bg white . centerXY . vcat . map hcat . chunk 4 . map draw $ cubes

main = defaultMain diagram

A: I just asked my professor for  hint, and with the hint I solved this problem. It's quite easy actually.
The hint is, suppose you have a $n\times n\times n$ cube. Color it with Color1, then move the bottom $n\times n\times 1$ cubes to the top. See what will happen.
The solution is, yes, and to do so you only need to repeat the move in the hint.
A: It's easy to do with a 4×4×4 cube too:


*

*8 cubes with 3 blue, 3 green faces

*8 cubes with 3 red, 3 yellow faces

*24 cubes with 2 blue, 2 green, 1 yellow, 1 red face

*24 cubes with 2 red, 2 yellow, 1 blue, 1 green face


In general, one way to proceed is to set up a table like this:
           colour 1     colour 2    ....    colour n
3 faces         8            8                   8
2 faces    12(n-2)      12(n-2)             12(n-2)
1 face      6(n-2)²      6(n-2)²             6(n-2)²
0 faces      (n-2)³       (n-2)³              (n-2)³

and then try partition them into $n^3$ disjoint collections of 6 faces, each with one set of faces from each colour.
