Home Blog About Us Work we do Content Contact Us

Newsletter: Click here to join an email list and be contacted when a new article is published.




Linus Sequences

This article is about the Linus Sequence. As far as I know, it’s the only number sequence that is named after a cartoon strip character (This being the internet, I’m sure I’ll rapidly learn if there are others! I’ll update this article if people contact me with other named sequences).

The Linus Sequence (OEIS: A006345) is named after the character, Linus van Pelt, from the popular Peanuts Cartoon. It’s in reference/homage to the cartoon strip see below:

The sequence was first described by Nathaniel Hellerstein, in 1978. It’s a sequence that, ironically, is extended by trying to make a “pattern-breaking pattern”.

The Linus sequence is a sequence of “Trues” and “Falses” in which each new entry to the end of the sequence is chosen to prevent the longest possible pattern from emerging at the end of the sequence.

Here are the first few entries:


Admittedly, this isn’t exactly the sequence that Linus was describing in the comic strip, but let’s take a closer look about how the sequence grows, and how, mathematically we make a “pattern-breaking pattern”.

Sequence Derivation

At each stage, there is a choice to add either a T or F to the end of the current sequence.

Which character is chosen, is the character that minimizes the length of any immediately repeated sequence that now occurs at the end. It’s a fun little exercise to knock out code to generate the sequence (it’s popular with code golfers).

It’s easy to see through example.

After the first T, if we added another T to the end, we’d get the repeated sequence of TT, which is two units long. Conversely, if we added a F to the end there is no repeat, so adding the F minimizes the repeating pattern at the end of the string.

If we added another F to the end, we’d get the repeated string FF at the end, so instead we revert to T.

We have to now add another T, otherwise, we’d end up with TFTF, which is double repeat of TF.

Adding another T to this string would result in TT at the end (length two), so instead we add another F.

After this. We can’t add another T as this would cause the repeated sequence TFT (the entire string would be TFTTFT), so we have the add F.

And so on …

It seems a little confusing at first, but the simple rule is that you select the character that avoids the longest possible “double suffix” forming at the end of the sequence.

First 500 terms

Here are the first 500 terms of the sequence:


It's more common to see this sequence expressed as numbers e.g. 1, 2, 1, 1, 2, 2, 1, 2, 1, 1, 2, 1, 2, 2, 1, 1 …

Sally Sequences

A closely related sequence, called the Sally Sequence, actually makes the Linus sequence even easier to understand. The Sally sequence donates the length of repetition that is avoided by selecting the correct option for the Linus sequence.

It is named after Sally, Charlie Brown’s little sister. Sally has a crush on Linus (her “Sweet Babboo”).

This is what the first few terms of the Sally Sequence look like:

0, 1, 1, 2, 1, 3, 1, 1, 3, 2, 1, 6, 3, 2, 1, 3, 1, 1, 6, 3, 2, 4, 1, 1, 3, 2, 1, 3, 1, 6, 4, 2, 1, 2, 4, 3, 1, 8 …

Interestingly, the values in the Sally Sequence appear quantized, in the first 1,000 terms, you only find the values: 0, 1, 2, 3, 4, 6, 8, 24, 30, 108 in the sequence.

If increase the window to 20,000 terms still the only values seen are: 0, 1, 2, 3, 4, 5, 6, 7, 8, 16, 18, 24, 30, 108, 528, 552, 1298, 2752, 5876.

If you calculate the sequent to 1,000,000 terms, the only vales seen are: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 15, 16, 18, 24, 30, 36, 60, 72, 108, 318, 372, 414, 420, 444, 522, 528, 546, 552, 1280, 1292, 1298, 1632, 2620, 2752, 5876, 6203, 6218, 13912, 14312, 17220, 17580, 31532, 87650.

Graphing the results

If we take T to be +1, and F to be -1, we can build a cumulative running total of the sequence like a drunken-man's walk. It's pretty easy to see the structure in this sequence from the this graph. Here is graphed the first 800 terms.

Similarly, here is a plot of the first 800 terms of the Sally Sequence.


For more information on the Peanuts comic strips, cartoons, characters, videos, shops, and museum, please visit the official Peanuts web page at peanuts.com


You can find a complete list of all the articles here.      Click here to receive email alerts on new articles.

© 2009-2017 DataGenetics    Privacy Policy