The Kolakoski sequence is a list of 1's and 2's. Each number can appear alone in a block of one, or next to another copy of the same number in a block of two. For example, a block of one 1 is "1" and a block of two 1's is "11".
The Kolakoski sequence is constructed so that the numbers in the sequence describe the lengths of the blocks in the sequence.
The sequence begins as follows:
These first seven numbers can be described as a block of one 1, followed by a block of two 2's, followed by a block of two 1's, followed by a block of one 2, followed by a block of one 1:
The lengths of each of those blocks, in order, are: one, two, two, one, one, or:
which you may recognize as the start of the Kolakoski sequence.
At the beginning of the pandemic, I started going on “random Kolakoski walks.” I walked 1 or 2 blocks according to the Kolakoski sequence, then turned randomly and repeated. The images above show possible random Kolakoski walk routes on a grid.
These are array plots of iterations of the Kolakoski sequence whose numbers of terms are perfect squares, which lend themselves well to square-shaped visualizations. The variations in pattern and randomness become evident as more terms are displayed from top left to bottom right. Click here to see the code