%I #32 Jul 25 2023 10:12:50
%S 1,2,2,3,3,1,1,1,2,2,2,3,1,2,3,3,1,1,2,2,3,3,3,1,2,2,3,3,3,1,1,1,2,3,
%T 1,1,2,2,3,3,3,1,1,1,2,2,2,3,1,1,2,2,3,3,3,1,1,1,2,2,2,3,1,2,3,3,1,1,
%U 1,2,3,1,1,2,2,3,3,3,1,1,1,2,2,2,3,1,2,3,3,1,1,2,2,3,3,3,1,2,3,3,1,1,2,2,2
%N Kolakoski-(1,2,3) sequence: a(n) is the length of the n-th run.
%C Old name was: Kolakoski variation using (1,2,3) starting with 1,2.
%C Partial sum sequence is expected to be asymptotic to 2*n.
%C From _Michel Dekking_, Jan 31 2018: (Start)
%C (a(n)) is the unique fixed point of the 3-block substitution beta given by
%C 111 -> 123, 112 -> 1233,
%C 122 -> 12233, 123 -> 122333,
%C 222 -> 112233, 223 -> 1122333,
%C 231 -> 112223, 233 -> 11222333,
%C 311 -> 11123, 312 -> 111233,
%C 331 -> 1112223, 333 -> 111222333.
%C Here BL3 := {111, 112, 122, 123, 222, 223, 231, 233, 311, 312, 331, 333} is the set of all words of length 3 occurring at a position 1 mod 3 in (a(n)). This can be seen by splitting the words beta(B) into words of length 3, and looking at the possible extensions of those words beta(B) that have a length which is not a multiple of 3. For example, beta(122) = 12233 can only be extended to 122331 or to 122333, and both words 331 and 333 are in BL3. Interestingly, BL3 is invariant for the permutation 1->3, 2->1, 3->2 (and its square).
%C Note: In general, a 3-block substitution beta maps a word w(1)...w(3n) to the word
%C beta(w(1)w(2)w(3))...beta(w(3n-2)w(3n-1)w(3n)).
%C If the length of a word w is 3n+r, with r=1 or r=2, then the last letter, respectively last 2 letters are ignored.
%C (End)
%C Conjecture: the frequencies of 1's, 2's and 3's in (a(n)) exist and are all equal to 1/3. This conjecture implies the conjecture of Benoit Cloitre on the partial sum sequence. - _Michel Dekking_, Jan 31 2018
%H Ivan Neretin, <a href="/A079729/b079729.txt">Table of n, a(n) for n = 1..10000</a>
%H Ulrich Reitebuch, Henriette-Sophie Lipschütz, and Konrad Polthier, <a href="https://archive.bridgesmathart.org/2023/bridges2023-481.html">Visualizing the Kolakoski Sequence</a>, Bridges Conf. Proc.; Math., Art, Music, Architecture, Culture (2023) 481-484.
%F Iterate beta: 122 -> 12233 ~ 122331 -> 122331112223 -> 12233111222312331122333, etc. Here a(6)=1 has been added to 12233 in step two to continue the iteration. - _Michel Dekking_, Jan 31 2018
%e Sequence begins: 1,2,2,3,3,1,1,1,2,2,2,3,1,2,3,3,1,1,... read it as: (1),(2,2),(3,3),(1,1,1),(2,2,2),(3),(1),(2),(3,3),(1,1),... then count the terms in parentheses to get: 1,2,2,3,3,1,1,1,2,2,... which is the same sequence.
%t seed = {1, 2, 3}; w = {}; i = 1; Do[w = Join[w, Array[seed[[Mod[i - 1, Length[seed]] + 1]] &, If[i > Length[w], seed, w][[i]]]]; i++, {n, 53}]; w (* _Ivan Neretin_, Apr 02 2015 *)
%o (PARI) a=[1,2,2];for(n=3,100,for(i=1,a[n],a=concat(a,1+((n-1)%3))));a; \\ _Benoit Cloitre_, Feb 13 2009
%Y Cf. A000002.
%K nonn
%O 1,2
%A _Benoit Cloitre_, Feb 17 2003
%E More terms from _Philippe Deléham_, Sep 24 2006
%E Name changed and text edited by _Michel Dekking_, Jan 31 2018