The Magic Number Is Two

Stop and think about this for a second: when we talk, we're already using code.

Words β€” spoken or written β€” are code. Language itself is a code, one you've been decoding since you were a kid. So when I say:

Pink elephant.

You understood me. You probably even saw a pink elephant in your head. 🐘

It's all about information and communication.

That's wild, if you sit with it. Right now, writing these words, I'm encoding a message into text. And you, reading this from wherever you are in the world, are decoding it. We agreed on a system β€” the alphabet, the language β€” a long time ago, and now it just works.

This idea messed with my head recently. Communication is encoding. Once you see it, you can't unsee it. And it turns out the same trick that powers human language powers every computer you've ever touched.

Let me show you.

Two cups

Here's our system. We've got two cups. Each cup can be up or down. That's it.

Up is @. Down is %.

You agree a cup can be one or the other, right? Good β€” that's the only thing I need you to agree to. From here on I'll just write @ and %, but keep those two cups in your head: every symbol is just a cup, up or down.

Now look at the combinations we can make with two of them side by side:

Cup 1Cup 2
@@
@%
%@
%%

Four combinations. Four ways to express something. So let's use them. Let's say each combination is a letter:

LetterCode
A@ @
B@ %
C% @
D% %

Now I add one more rule: a space between letters, so you know where one ends and the next begins. (In real life with cups, you'd just lift both off the table for a second.) Watch what happens when I write this:

% @   @ @   @ %

Check it against the table. % @ is C, @ @ is A, @ % is B.

I just wrote CAB. With nothing but cups.

That's beautiful to me. Two patterns and a pause, and we communicated.

We run out fast

But four combinations only gets us to D. The alphabet has 26 letters. We're stuck.

The fix is obvious: add another cup. Three cups instead of two. More cups, more combinations, more letters.

CodeLetter
@ @ @A
@ @ %B
@ % @C
@ % %D
……and so on

But here's the annoying part. How far does three cups get us? Technically I'd have to draw out every combination just to find out β€” and then do it again for four cups, for five, for six. I'd be sketching little @ and % patterns all day.

There has to be a shortcut.

The shortcut

There is, and it's simple.

Take the number of patterns and multiply it by itself once per cup.

We have two patterns (@ and %). With two cups:

$$2 \times 2 = 4$$

Four combinations β€” exactly what we counted by hand for A through D. With three cups:

$$2 \times 2 \times 2 = 8$$

Or, cleaner:

$$2^2 = 4 \qquad 2^3 = 8 \qquad 2^4 = 16 \qquad 2^5 = 32$$

The base is the number of patterns. The exponent is the number of cups. That's the whole trick. Now I never have to draw combinations to count them β€” I just count cups.

So how many cups do I need to cover all 26 letters?

Four cups gives me $2^4 = 16$. Not enough. Five cups gives me $2^5 = 32$. That covers all 26 letters and leaves 6 combinations to spare.

Five cups it is. And now β€” now that I know 5 is the number β€” I draw the table. Just once, just for the size I actually need:

LetterCodeLetterCode
A@ @ @ @ @N@ % % @ %
B@ @ @ @ %O@ % % % @
C@ @ @ % @P@ % % % %
D@ @ @ % %Q% @ @ @ @
E@ @ % @ @R% @ @ @ %
F@ @ % @ %S% @ @ % @
G@ @ % % @T% @ @ % %
H@ @ % % %U% @ % @ @
I@ % @ @ @V% @ % @ %
J@ % @ @ %W% @ % % @
K@ % @ % @X% @ % % %
L@ % @ % %Y% % @ @ @
M@ % % @ @Z% % @ @ %

That's all 26 letters, running from @@@@@ up to %%@@%.

Decode it yourself

Let's put the table to work. Here's a four-letter message β€” try it before you read ahead:

@ @ @ % @   @ % % % @   @ @ @ % %   @ @ % @ @

Take your time. Letter by letter, against the table.

CodeLetter
@ @ @ % @C
@ % % % @O
@ @ @ % %D
@ @ % @ @E

CODE. You just decoded a word from raw cups-up, cups-down. Feels good, right? You and I never spoke β€” we just agreed on a table, and the meaning came through.

The empty seats

Here's a loose thread I want to leave dangling.

Five cups give us 32 combinations. The alphabet only needed 26. So six codes are sitting there empty β€” everything from %%@%@ up to %%%%%:

CodeLetter
% % @ % @?
% % @ % %?
% % % @ @?
% % % @ %?
% % % % @?
% % % % %?

Six free seats. We could fill them with numbers, punctuation, a space character β€” or something cleverer. What would you put there? Hold onto that question; it's a whole rabbit hole of its own, and I want to come back to it.

So... what did we just build?

Let's zoom back out to the math for a second.

Our base was 2. Two patterns. Two possibilities β€” the cup is this or that, up or down, one or the other.

When something has exactly two possible states, we call it binary.

Wait. Binary?

Yeah. That's it. That's the big scary word. You just built binary from scratch, with two cups and a rule you agreed to. The @ and % were always a 1 and a 0. The cups were always bits.

It was never magic. It was never something only computers understand. It's a system β€” and you could've invented it yourself. You basically just did.