The Polybius square is one of the oldest coordinate ciphers, turning each letter into a pair of numbers. This variant stretches the idea into three dimensions: a 3×3×3 cube with 27 cells, one for each of the 26 letters plus a period, so every character becomes an X-Y-Z triplet of single digits.
How it works
The 27 characters fill the cube in order. A character’s index n (0 to 26) is
decomposed like a base-3 number into a layer, row, and column:
z (layer) = floor(n / 9) + 1
y (row) = floor((n mod 9) / 3) + 1
x (column) = (n mod 3) + 1
output = "x y z" (each 1..3)
Decoding reverses the arithmetic: index = (z-1)*9 + (y-1)*3 + (x-1), then the
character at that index is looked up. Because the mapping is a simple bijection,
encode and decode are exact inverses.
Why 3×3×3 solves the 26-letter problem
The classic 5×5 Polybius square has 25 cells, one short of the 26-letter Latin alphabet, so it must merge two letters — traditionally I and J. A 3×3×3 cube has exactly 27 cells, which fits all 26 letters with one slot left over (used here for a period). No merging is needed, and every character maps to a unique, unambiguous triplet.
The tradeoff is that each encoded character becomes three digits rather than two, so output is 50% longer than a standard Polybius square encoding. For a short puzzle or teaching exercise that is no problem; for large texts the verbosity becomes apparent quickly.
Mapping the first layer
The first layer (z=1) holds indices 0–8, corresponding to A through I:
| x=1 | x=2 | x=3 | |
|---|---|---|---|
| y=1 | A (111) | B (211) | C (311) |
| y=2 | D (121) | E (221) | F (321) |
| y=3 | G (131) | H (231) | I (331) |
Layer z=2 holds J through R, and layer z=3 holds S through Z plus the period. J is the first cell of the second layer: index 9 → x=1, y=1, z=2 → output 112.
Educational uses
The 3D cube is a clean way to introduce base-3 representation to students: the three coordinate digits are exactly the base-3 digits of the character index. Asking a student to decode 112 221 331 111 by working out the base-3 arithmetic by hand (recovering J, E, I, A) reinforces place-value thinking in a context more engaging than a textbook exercise.
It also illustrates why coordinate ciphers provide no real security: the output uses only three distinct symbols (1, 2, 3), each letter maps to a unique fixed triplet, and frequency analysis on a long enough ciphertext reconstructs the key instantly.