Probability of a painted cube being reassembled into itself Suppose 27 cubes are stacked together, suspended in the air, to form a larger cube.
The cube is then painted on all the exposed surfaces and dried.
The smaller cubes are then randomly permuted in both spatial position and spatial orientation to form another large cube.
What is the probability that new larger cube is identical to the original?
This is not homework, it was passed on by a friend who found it somewhere on the internet, and they do not remember where.

There are $27$ cubies of four types:


*

*one body cubie (B),

*six face cubies (F),

*twelve edge cubies (E), and

*eight vertex cubies (V).


We can represent the cubie types occupying the $27$ cubie positions by a $27$-letter word using the letters B, F, E, and V with the multiplicities above.  The number of distinct such words, all of which are equally likely and only one of which matches that of the original arrangement, is given by the multinomial coefficient
$$
\binom{27}{1,6,12,8}=\frac{27!}{1!\cdot6!\cdot12!\cdot8!}.
$$
Now for how each of the cubie types might appear.


*

*There is only one way the body cubie can appear (i.e. with no faces painted).

*There are six ways a face cubie can appear (e.g. front face painted, top face painted, etc.)  In fact these six possible appearances are precisely those realized by the six face cubies in the original arrangement—one of the six has its front face painted, one its top face painted, and so on.

*Similarly, there are twelve ways an edge cubie can appear (e.g. front and top painted, front and left painted), each realized by one of the twelve edge cubies in the original arrangement.

*Likewise there are eight ways a vertex cubie can appear.


Putting together the type information and the appearance information for each of the cubies, there are
$$
\binom{27}{1,6,12,8}\cdot1^1\cdot6^6\cdot12^{12}\cdot8^8
$$
distinct arrangements, each of which has the same probability and only one of which matches the original arrangement.  Hence the probability of matching the original arrangement is the reciprocal of this number.
