Problem 4: Oldenburger-Kolakoski Sequence |
The Oldenburger-Kolakoski sequence is an autodescriptive and self-generating infinite sequence of symbols $\{\sa{1},\sa{2}\}$. More technically, it is its own run-length encoding. The sequence, denoted here by $\K$, is one of the strangest sequences. Despite the simplicity of its generation it appears to have a random behaviour.
By a block of letters in a word we mean a run of letters, that is, a maximal factor consisting of occurrences of the same letter. The operation $\blocks(S)$ replaces each block of a word $S$ by its length. For example, $$\blocks(\sa{2}\,\sa{1}\,\sa{1}\,\sa{1}\,\sa{2}\,\sa{2}\,\sa{1}\,\sa{2}\,\sa{2}\,\sa{2}) =\sa{1}\,\sa{3}\,\sa{2}\,\sa{1}\,\sa{3}.$$
The sequence $\K$ is the unique infinite sequence over the alphabet $\{\sa{1},\sa{2}\}$ that starts with $\sa{2}$ and satisfies $\blocks(\K)=\K$.
Remark. Usually the sequence is defined to start with $\sa{1}$, but it is more convenient here that it starts with $\sa{2}$. In fact, these are the same sequences after removing the first occurrence of $\sa{1}$.
The very small space used for the generation of $\K$ is the most interesting element of the question.