Look-and-say sequence

O(L) per term, L grows ~30%/term

The look-and-say sequence was analysed by mathematician John Conway, who proved that its terms grow at a constant rate of about 30% per step and ultimately decompose into 92 stable atomic subsequences he called "elements". Starting from "1": one 1 → "11"; two 1s → "21"; one 2 and one 1 → "1211", and so on. Despite the chaotic appearance, the long-run growth factor (Conway's constant) is a root of a specific 71st-degree polynomial. The visualizer shows each term as a string cell and stops before terms grow too large to display.

Sequence
Press ▶ to run
Edit the input and press Play

How it works

  1. Start with the seed string (decimal representation of n).
  2. Scan left to right, counting runs of equal digits.
  3. Write each run as its count followed by the digit.
  4. Repeat up to 8 terms or until a term exceeds 40 characters.

Pseudocode

1lookAndSay(n):                      # O(L) per term, L grows ~30%/term2  term ← str(n)3  emit term4  repeat up to 8 times:5    next ← ""6    for each run of equal digits in term:7      next += str(count) + digit8    if len(next) > 40: stop9    term ← next10    emit term