How many different cubes can you paint with six colors?

Counting
Medium
A permutations and combinations puzzle about painting a cube and turning it.
Published

November 16, 2026

NoteQuestion

You paint the six faces of a cube with six different colors, one color per face. Two cubes are the same when you can turn one until it looks exactly like the other. How many different cubes can you paint?

Try it first, then open the solution.

The answer is 30. The count starts from permutations and then removes the orders that count as the same, as combinations do, but only some of them.

A permutation counts arrangements in which the order matters. Arranging \(k\) of \(n\) different items in order gives

\[\begin{aligned} P(n, k) &= n \times (n-1) \times \cdots \times (n-k+1) \\ &= \frac{n!}{(n-k)!}, \end{aligned} \tag{1}\]

where \(n!\), read “n factorial”, is \(n \times (n-1) \times \cdots \times 2 \times 1\). For gold, silver and bronze among 10 runners, \(P(10, 3) = 10 \times 9 \times 8 = 720\) podiums.

A combination counts selections in which the order does not matter. It divides the permutations by the \(k!\) orders of each choice:

\[C(n, k) = \frac{P(n, k)}{k!} = \frac{n!}{k!\,(n-k)!}. \tag{2}\]

For 3 of 10 stocks, \(C(10, 3) = 720 / 3! = 120\) portfolios. The two formulas apply whatever the items are: runners, skaters, stocks or cards.

Neither formula fits the cube as it is. Held still, its six positions take the six colors in \(P(6, 6) = 6! = 720\) orders, a permutation, but that counts every turn of the same cube as a new cube. A combination would divide by all \(6!\) orders and leave 1 cube. The cube needs a modification in between. You can spin it from left to right and tip it from top to bottom, so you divide only by the number of turns:

\[\text{cubes} = \frac{n!}{T} = \frac{6!}{6 \times 4} = \frac{720}{24} = 30, \tag{3}\]

where \(n = 6\) is the number of colors and \(T = 6 \times 4 = 24\) the number of turns of one cube: any of its 6 faces on top, then any of its 4 side faces in front.

The animation shows where the 720 and the 24 come from.

Why six different colors on a cube give 30 different cubes: 720 permutations, 24 turns per cube

A cube and its mirror image count as two cubes, because no turn makes one into the other.

The common wrong answers each divide by the wrong number:

Answer The slip
720 counts every turn of a cube as a new cube
720 / 6 = 120 forgets the 4 spins on the table
720 / 4 = 180 forgets that any face can be on top
720 / 48 = 15 counts a cube and its mirror image as the same
from itertools import permutations

POSITIONS = ['top', 'bottom', 'front', 'right', 'back', 'left']
SPIN = {'front': 'right', 'right': 'back', 'back': 'left', 'left': 'front'}
TIP = {'top': 'back', 'front': 'top', 'bottom': 'front', 'back': 'bottom'}


def turn(painting, move):
    return tuple(painting[POSITIONS.index(move.get(p, p))] for p in POSITIONS)


def all_turns(painting):
    seen, todo = {painting}, [painting]
    while todo:
        current = todo.pop()
        for move in (SPIN, TIP):
            turned = turn(current, move)
            if turned not in seen:
                seen.add(turned)
                todo.append(turned)
    return seen


paintings = set(permutations(['red', 'blue', 'green', 'yellow', 'white', 'black']))
cubes = {min(all_turns(painting)) for painting in paintings}
print(len(paintings), len(all_turns(min(paintings))), len(cubes))
720 24 30