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.

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

