Can flashlights speak?
Speech can be made to correspond to words. And words are sequences of letters. So, roughly, can we communicate letters with a flashlight? No sounds allowed.
Well, what can we do with a flashlight? Turn it on and off. So we can blink light. Here’s a thought: One blink means $a$. Two blinks means $b$. Three blinks means $c$. Four blinks means $d$. And so on.
Here’s the rub: how do we know when one letter stops, and another begins. Put another way, does 7 blinks mean $(g)$, or $(b, a, d)$, since 2 + 1 + 4 = 7, or $(c, d)$, since 3 + 4 = 7, or $(d, c)$ and so on. If we change the game, maybe we can change the color of the flashlight. Or give a half-flash. Is a half-flash a “quick” flash, or is it a flash in which we have covered up half of the end of the flashlight?
The first question is a clue. The duration of the blink. How about the duration between blinks? A one second pause in between blinks of a particular a letter. A three second pause for blinks in between letters. A five second pause for a space, to indicate a change of a word? Or an additional symbol, a “space”, in our alphabet, communicated with 27 (!) blinks?
Denote a blink by $\blink$. The flash code1 for the alphabet $A$ (the latin lower case letters) is the function $f: A \to \str(\set{\blink})$ defined by $f(a) = \blink$, $f(b) = \blink\blink$, $f(c) = \blink\blink\blink$, $f(c) = \blink\blink\blink\blink$ and so on. We call $f(a)$ the code word of $a \in A$. It is a sequence of blinks.
The idea is that if we give someone the code word $f(a)$ for a letter of our alphabet $a \in A$, they will be able to tell us $a$. In the language of functions, we want $f$ to have an inverse. Clearly, $f$ is invertible.
It is natural to extend the flash code for $A$ to strings of $A$. Let $\pause$ represent a long pause. Then we encode a sequence $x \in \str(A)$ by applying $f$ to each element of $x$ in turn, and including a $\square$ in between. The flash code for the strings $\str(A)$ is the function $g: \str(A) \to \str(\set{\blink, \pause})$ defined recursively, as $g(x) = f(x_1)$ if $\num{x} = 1$ and $g(x) = f(x_1)\pause g(x_{2:n})$ when $\num{x} > 1$. For example, we encode the word (string) $(b,a,d)$ as