Kolakoski Sequence

60 points12 comments6 days ago
MontyCarloHall

For those not getting this immediately (I sure didn't):

              _____________
   sequence   1 2 2 1 1 2 1 2 2 1
   run lens   1 2-- 2-- 1 1 2-- 1
Read out the bottom sequence of run lengths, and be amazed that it's the same as the first 7 digits as the top sequence. Extend the bottom to continue to recapitulate the top sequence, and add terms to the top sequence accordingly to reflect the run lengths in the bottom sequence. Repeat infinitely.
show comments
nwellnhof

There's a fascinating way to generate the Kolakoski sequence with bit fiddling: https://11011110.github.io/blog/2016/10/14/kolakoski-sequenc...

vindex10

Is it a coincidence that it is number 2 in the OEIS?)

globalnode

does it repeat? or is it like pi? -- oh the wiki says its an infinite sequence. that might be handy for generating pseudo random numbers i guess. i wonder if theres a function that generates the correct digit at position n? doh, wiki says theres a recursive formula for the i'th term.