How We Pack Your Name Into Fewer Bits
A clever 1952 compression trick lets us squeeze a name into a fraction of the space — and that's what makes finding your prime feasible.
Once your name has been tidied up, it’s a string of capital letters, spaces, hyphens, and apostrophes. Now we need to turn it into a sequence of zeros and ones small enough to fit inside a prime number alongside everything else the puzzle needs.
Here’s the catch: we have very little room.
The naive approach, and why it doesn’t work
The obvious way to encode a letter is the one your computer uses every day: ASCII. Each character gets 8 bits, like a fixed-size envelope. The letter A is 01000001. B is 01000010. And so on.
Tidy and predictable. But for our purposes, enormously wasteful.
We only have 29 different symbols to encode (26 uppercase letters + space + apostrophe + hyphen). 8 bits gives us 256 possible values, so we’re using less than 12% of what we paid for. And those 8 bits per character add up fast: ALEXANDER would eat 72 bits, even though there’s no real information density behind most of those zeros.
For our smallest puzzle size — a 64-bit prime — there literally wouldn’t be enough room. We’d hit the ceiling before we finished encoding the name, leaving zero room for the prime-hunting math.
A graduate student saves the day
In 1951, a young grad student at MIT named David Huffman was given a homework assignment instead of a final exam: find the most efficient way to represent symbols when some are more common than others. He thought about it for a while, came up with an algorithm so elegant it’s still used everywhere from ZIP files to JPEG images, turned it in, and earned a permanent place in computer science history.
The idea is delightfully simple: common letters get short codes, rare letters get long ones.
In English names, E and A and spaces are everywhere; Q and Z are rare guests. So we hand E a short codeword (just 3 bits) and Q a longer one. Average it out across a typical name, and you end up using somewhere around 3 to 5 bits per character instead of 8.
ASCII Encoding: [ 8 bits ][ 8 bits ][ 8 bits ][ 8 bits ] = 32 bits
Huffman Encoding: [ 3b ][ 3b ][ 4b ][ 3b ] = 13 bits (60% smaller!)
That’s not a small saving. It’s the difference between fitting inside a compact prime number and not fitting at all.
(For the deeper dive into how Huffman’s algorithm mathematically builds these optimal prefix trees, see Huffman Coding: Squeezing Names into Fewer Bits.)
What we actually pack into the prime
Inside every reversible candidate block, the bits for your name are arranged with surgical precision:
- A 6-bit length prefix. This records the number of characters in your tidy name (from 1 to 63).
- The Huffman-encoded characters. A variable-length bitstream where each letter is represented by its unique prefix-free code.
- The nonce region. A buffer of free bits adjusted during the prime hunt until the number passes Miller–Rabin primality testing.
- The pin bit. A single forced
1at the very top to lock down the block size (64, 96, or 128 bits).
Why record the count of characters rather than the count of bits?
Because during reverse decoding, the decoder doesn’t know the bit lengths in advance! The decoder walks the Huffman tree one bit at a time, emits one character each time it reaches a leaf, and counts down until all characters are recovered. “Decode exactly 7 characters” is an airtight instruction. “Decode bits until something feels right” is a recipe for chaos.
Why the savings matter
Every bit we save on encoding your name is a bit we can hand over to the nonce—the small region of free bits that our search loop nudges around until the whole block becomes a certified prime number.
More nonce headroom means more candidate numbers to test, which guarantees we find your prime in milliseconds without ever running out of room.
In other words: David Huffman’s 1952 breakthrough is the engine that lets your name, your 3-character lock, and your prime number coexist in a single, elegant mathematical object.
The “From Name to Prime & Back” Series
Follow the complete journey of how a name transforms into a prime number and back:
- First, We Tidy Your Name — Standardizing characters, accents, and spaces.
- Packing Your Name Into Fewer Bits — (You are here) How Huffman compression makes the puzzle fit.
- Your Tiny Key and the Number Lock — Feistel ciphers and why 3-character keys are fun.
- Prime Hunting With Tiny Tweaks — Wiggling nonces and the Miller–Rabin primality test.
- How Decoding Works (Backwards Magic) — Running the pipeline in reverse to recover your name.
- Share the Prime, Protect the Key — Keeping your name private until you choose to reveal it.
Companion Deep Dives:
- Huffman Coding: Squeezing Names into Fewer Bits — The mathematics of optimal binary prefix trees.
- The Miller–Rabin Test — How we verify primality in microseconds without trial division.
- Organic, Artisanal Math — Why deterministic algorithms beat AI hallucinations.