⏱️ Lectura: 10 min

The 3x3x3 Rubik’s Cube has exactly 43,252,003,274,489,856,000 legal positions, about 43 quintillion, and the site Every Cube lets you jump to any of them by typing its index number, without generating a single one of the previous ones.

📑 En este artículo
  1. TL;DR
  2. Introduction
  3. What Happened
  4. Context and History
  5. Technical Details: How Rubik’s Cube Positions Are Indexed
  6. How to Test It
  7. Impact and Analysis
  8. What’s Next
  9. Frequently Asked Questions
    1. How many positions does the 3x3x3 Rubik’s Cube actually have?
    2. What is the Superflip position?
    3. Why is the maximum number of moves 20?
    4. How can you jump to a position without generating all the previous ones?
    5. Is the total number of mathematical positions the same as the number of positions reachable by playing?
    6. What’s the difference between the 2D and 3D views in Every Cube?
  10. References

The trick isn’t brute force: it’s a classic combinatorics problem called ranking and unranking of permutations, solved with a factorial number system known as the Lehmer code. Here we walk through that math and how to code it.

TL;DR

  • The 3x3x3 Rubik’s Cube has 43,252,003,274,489,856,000 legal positions, which can be calculated exactly from group theory.
  • Every Cube (everycube.alen.is) assigns a unique index to each position and lets you jump straight to any of them, with 2D and 3D views.
  • The site highlights famous positions: Superflip (all 12 edges flipped, corners intact) and Checkerboard (checkerboard pattern).
  • Superflip needs 20 moves to solve in face-turn metric, the maximum possible according to ‘God’s Number’, proven in 2010.
  • Jumping to position N without enumerating all of them requires a factorial number system (Lehmer code) combined with base-3 and base-2 digits.
  • The total breaks down into 8! corner permutations (40,320), 3^7 orientations (2,187), 12! edge permutations (479,001,600), and 2^11 orientations (2,048), divided by 2 for parity.
  • Without the physical assembly restriction, the total rises to 519,024,039,293,878,272,000: twelve times more than the positions reachable through legal moves.

Introduction

Every Cube starts from a simple idea to expose: every position of the Rubik’s Cube has a number. You type that number, the site calculates on the spot which position it corresponds to, and draws it. There’s no database with 43 quintillion rows behind it: there’s an algorithm that translates an index into a piece configuration without passing through the previous ones.

That turns a 1974 toy into a practical demonstration of a much more general computer science problem: how to enumerate, index, and jump within a gigantic combinatorial space without traversing it entirely.

What Happened

The site everycube.alen.is offers an index box where visitors type any number between 1 and 43,252,003,274,489,856,000, and the corresponding cube position renders instantly. It includes toggles to view the cube in 2D or 3D, a visual effects (FX) button, and standard move notation (like R’, a counterclockwise turn of the right face) to describe how to reach that position from the solved state.

It also includes a list of positions marked as favorites with proper names, among them Superflip and Checkerboard. Superflip is the position where the eight corners remain in their correct place and orientation, but all twelve edges are flipped 180 degrees: each face of the cube looks solved in color, but every edge piece is reversed. Checkerboard is the chessboard pattern, where each face alternates its colors diagonally.

Rubik's Cube in the Superflip position with all edges inverted
Superflip: corners solved, all 12 edges flipped 180 degrees. Foto de Michelen Studios en Unsplash

Context and History

The Rubik’s Cube was invented by Hungarian Ernő Rubik in 1974 as a sculpture and geometry exercise, not as a puzzle. Its internal structure (a core with axes and 26 moving pieces around it) turned out to be, without that being the plan, a physical representation of a mathematical group: each face turn is an element of the group, and composing turns is multiplying group elements.

That algebraic reading of the cube led to a question that took decades to answer: what is the minimum number of moves needed to solve any position, in the worst case? That number is known as ‘God’s Number’. The earliest lower bounds hovered around 18 moves in the 1990s; reducing the upper bound required splitting the 43,252,003,274,489,856,000 positions into about 56 million symmetry classes and solving each class with computer-assisted search.

In 2010, the team of Tomas Rokicki, Herbert Kociemba, Morley Davidson, and John Dethridge finished that computation (with processing time donated by Google) and published proof that every cube position can be solved in 20 moves or fewer, and that positions exist, like Superflip, that actually require all 20. Since then, 20 has been a closed number: it neither goes down nor up.

Technical Details: How Rubik’s Cube Positions Are Indexed

The total of 43,252,003,274,489,856,000 isn’t an estimate: it comes from separately counting the permutation and orientation of the corners, and the permutation and orientation of the edges, then dividing by 2 due to a parity restriction. The Wikipedia page on the Rubik’s Cube group documents the full formula:

State componentNumber of possible valuesEncoding used
Permutation of the 8 corners8! = 40,320Lehmer code in decreasing factorial base (7!, 6!, …, 1!)
Orientation of the 8 corners3^7 = 2,1877 digits in base 3 (the eighth corner is inferred by sum modulo 3)
Permutation of the 12 edges12! = 479,001,600Lehmer code in decreasing factorial base (11!, 10!, …, 1!)
Orientation of the 12 edges2^11 = 2,04811 digits in base 2 (the twelfth edge is inferred by sum modulo 2)

Multiplying the four columns and dividing by 2 (because corner permutation parity always has to match edge permutation parity) gives exactly 43,252,003,274,489,856,000.

⚠️ Heads up: if you ignore that parity restriction and multiply the four columns without dividing by 2, the result is 519,024,039,293,878,272,000: twelve times more. Those extra combinations are only reachable by disassembling the cube and reassembling it incorrectly, never by turning faces.

Jumping to position number N without generating the previous ones requires the same trick used by test case generators that shuffle card decks: the Lehmer code, a number system where each digit’s base is a decreasing factorial instead of a fixed power. Converting a number to that base (unranking) directly gives the permutation at position N, without passing through N-1.

flowchart TD
A["Index N between 0 and 43,252,003,274,489,856,000"] --> B["Split by division and modulo across the 4 blocks"]
B --> C["Corner permutation: factorial unranking in base 8!"]
B --> D["Corner orientation: base 3 digits"]
B --> E["Edge permutation: factorial unranking in base 12!"]
B --> F["Edge orientation: base 2 digits"]
C --> G["Complete cube state"]
D --> G
E --> G
F --> G

In code, unranking a permutation looks like this:

import math

def unrank_permutation(rank, elementos):
    elementos = list(elementos)
    permutacion = []
    n = len(elementos)
    for i in range(n, 0, -1):
        base = math.factorial(i - 1)
        indice = rank // base
        rank %= base
        permutacion.append(elementos.pop(indice))
    return permutacion

# Permutation number 5 (base 0) of 4 elements, without generating the 4 previous ones
print(unrank_permutation(5, ["A", "B", "C", "D"]))
# ['A', 'D', 'C', 'B']

That snippet solves the generic 4-element case. For the cube’s 4 components (permutation and orientation of corners and edges) they need to be combined into a single mixed index, dividing successively by the size of each block:

import math

CORNER_PERMS = math.factorial(8)   # 40320
CORNER_ORIENTS = 3 ** 7             # 2187
EDGE_PERMS = math.factorial(12)     # 479001600
EDGE_ORIENTS = 2 ** 11               # 2048

def unrank_estado_cubo(indice):
    indice, orient_bordes = divmod(indice, EDGE_ORIENTS)
    indice, perm_bordes = divmod(indice, EDGE_PERMS)
    indice, orient_esquinas = divmod(indice, CORNER_ORIENTS)
    perm_esquinas = indice  # what's left fits in 0..CORNER_PERMS-1
    return {
        "permutacion_esquinas": perm_esquinas,
        "orientacion_esquinas": orient_esquinas,
        "permutacion_bordes": perm_bordes,
        "orientacion_bordes": orient_bordes,
    }

print(unrank_estado_cubo(0))
# solved position: all four fields at zero

That scheme is a didactic simplification: it doesn’t yet apply the division by 2 for parity, so any given N could land on a combination of permutations that never actually appears when turning a physical cube. A ranking faithful to the real group needs an extra step that fixes the edge permutation based on the already-decoded corner permutation parity, rather than treating it as independent.

How to Test It

To experiment with the idea without writing the cube’s full unranking, the generic permutation snippet above is enough. The way to confirm that an unranking implementation is correct is to make the round trip: converting a permutation to its index (ranking) and that index back to the permutation (unranking) has to return exactly the same thing.

def rank_permutation(permutacion):
    elementos = sorted(permutacion)
    rank = 0
    n = len(permutacion)
    for i, valor in enumerate(permutacion):
        indice = elementos.index(valor)
        rank += indice * math.factorial(n - 1 - i)
        elementos.pop(indice)
    return rank

assert rank_permutation(unrank_permutation(5, ["A", "B", "C", "D"])) == 5

If that assert doesn’t fail, the rank/unrank pair is consistent. On everycube.alen.is the equivalent is typing an index, looking at the position in 3D, and jotting down the move sequence the site shows to get there from the solved state.

checkerboard pattern on a Rubik's Cube viewed in 3D
Checkerboard: same 43-quintillion space, a different index. Foto de William Warby en Unsplash

Impact and Analysis

The interest of Every Cube isn’t the cube itself, but that it exposes live a technique that’s normally hidden inside other tools: reproducible card deck shufflers generated from a seed, Sudoku-type puzzle engines that need to enumerate valid boards, or reversible ID schemes that encode a permutation without storing it whole on disk.

💡 Tip: the Lehmer code isn’t exclusive to the Rubik’s Cube. It’s the same technique behind reproducibly shuffling cards from a seed, or generating unique, reversible identifiers without storing a table with every possible value.

The figure of 43,252,003,274,489,856,000 also serves as a yardstick for understanding how fast combinatorial spaces grow: adding a single dimension (going from a 3x3x3 cube to a 4x4x4 one, for example) sends the count up several orders of magnitude, because each new piece multiplies, not adds, the possibilities.

What’s Next

Tools of this kind tend to grow by adding automatic solvers (showing the optimal move sequence for any index, not just the position) or extending to other puzzles in the same mathematical family, like the 2x2x2 cube or the Megaminx, whose permutation groups are calculated with the same permutation-plus-orientation decomposition logic.

📖 Summary on Telegram: View summary

Try it yourself: open everycube.alen.is, type a random index between 1 and 43,252,003,274,489,856,000, and see what position it returns in the 3D view.

Frequently Asked Questions

How many positions does the 3x3x3 Rubik’s Cube actually have?

43,252,003,274,489,856,000, a number that comes from multiplying the permutations and orientations of the 8 corners and 12 edges, then dividing by 2 for the parity restriction between both piece groups.

What is the Superflip position?

It’s the position where the 8 corners are solved (in their correct place and orientation) but all 12 edges are flipped 180 degrees. It’s one of the positions that needs the maximum of 20 moves to solve.

Why is the maximum number of moves 20?

Because in 2010 a team led by Tomas Rokicki proved, through exhaustive computer-assisted search over symmetry classes, that none of the 43,252,003,274,489,856,000 positions needs more than 20 face turns, and that positions exist, like Superflip, that actually require all 20.

How can you jump to a position without generating all the previous ones?

By encoding the permutation in a factorial number system (Lehmer code): each digit’s base is a decreasing factorial instead of a fixed power, which allows converting an index directly into the corresponding permutation without going through the previous ones.

Is the total number of mathematical positions the same as the number of positions reachable by playing?

No. If the physical assembly restriction is ignored, the count rises to 519,024,039,293,878,272,000, twelve times more than the 43,252,003,274,489,856,000 reachable by turning faces without disassembling the cube.

What’s the difference between the 2D and 3D views in Every Cube?

The 2D view shows the flat unfolding of the cube’s six faces, useful for reading colors quickly; the 3D view renders the cube as an object, useful for understanding the real orientation of each piece in space.

References

📱 Enjoying this content? Follow @programacion on Telegram for daily tech content in Spanish: quick summaries, fresh content every day.

Imagen destacada: Foto de Nick Fewings en Unsplash

Categories: Noticias Tech

Andrés Morales

Developer and AI researcher. Writes about language models, frameworks, developer tooling, and open source releases. Covers ML papers, the tech startup ecosystem, and programming trends.

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.