login
Successive generations of the Kolakoski sequence A000002.
11

%I #9 Jan 12 2021 21:34:11

%S 1,12,1221,1221121,12211212212,122112122122112112,

%T 1221121221221121122121121221,

%U 1221121221221121122121121221121121221221121,12211212212211211221211212211211212212211212212112112212211212212

%N Successive generations of the Kolakoski sequence A000002.

%o (Python)

%o from itertools import accumulate, groupby, repeat

%o def K(n, _):

%o c, s = "12", ""

%o for i, k in enumerate(str(n)): s += c[i%2]*int(k)

%o return int(s + c[(i+1)%2])

%o def aupton(nn): return list(accumulate(repeat(1, nn+1), K))

%o print(aupton(8)) # _Michael S. Branicky_, Jan 12 2021

%Y Cf. A054348, A054349, A054350, A054352, A042942, A000002.

%Y Word lengths give A054352.

%K nonn,easy

%O 0,2

%A _N. J. A. Sloane_, May 07 2000

%E More terms from Antonio G. Astudillo (afg_astudillo(AT)lycos.com), Apr 05 2003