%I
%S 1,1,2,1,1,2,1,2,2,1,1,2,1,1,2,2,1,2,1,1,2,1,1,2,2,1,2,2,1,1,2,1,2,2,
%T 1,2,1,1,2,1,1,2,2,1,2,1,1,2,1,2,2,1,1,2,1,1,2,2,1,2,2,1,2,1,1,2,1,1,
%U 2,2,1,2,1,1,2,1,2,2,1,1,2,1,1,2,1,2,2,1
%N a(n) = 1, unless forbidden by the "iterated cubefree rule", in which case a(n) = 2.
%C Inspired by the Kolakoski sequence A000002.
%C The "iterated cubefree rule" defined here means that the sequence a does not contain words repeated three times, and neither does any of the sequences RL^n(a), n >= 0, where RL is the runlength transform (in other words, the sequence a is smooth, that is differentiable arbitrarily many times  see for example the link by Fedou and Fici for a definition of differentiable sequences). The OK sequence A000002 obviously satisfies this rule because RL(OK)=OK.
%C The patterns appearing in this sequence look very similar to those in A000002. Indeed, the frequency of terms which value is not constrained by the iterated cubefree rule diminishes as n increases in both sequences and seems to tend to zero (A250006 gives the ranks of these terms for this sequence).
%C Thus all binary sequence satisfying the iterated cubefree rule might share similar limiting properties, in particular: does the limiting frequency of 1's exist for such a sequence? If yes, is it equal to 1/2, despite the priority given to 1's in this sequence?
%H JeanChristophe HervĂ©, <a href="/A250005/b250005.txt">Table of n, a(n) for n = 1..10000</a>
%H F. M. Dekking, <a href="http://www.digizeitschriften.de/dms/resolveppn/?PPN=GDZPPN002544490">On the structure of selfgenerating sequences</a>, Seminar on Number Theory, 19801981 (Talence, 19801981), Exp. No. 31, 6 pp., Univ. Bordeaux I, Talence, 1981. Math. Rev. 83e:10075.
%H J. M. Fedou and G. Fici, <a href="http://www.cs.uwaterloo.ca/journals/JIS/VOL13/Fici/fici.html">Some remarks on differentiable sequences and recursivity</a>, Journal of Integer Sequences 13(3): Article 10.3.2 (2010).
%H C. Kimberling, Integer Sequences and Arrays, <a href="http://faculty.evansville.edu/ck6/integer/index.html">Illustration of the Kolakoski sequence</a>
%H W. Kolakoski and N. Ucoluk, <a href="http://www.jstor.org/stable/2314839">Problem 5304: Self Generating Runs</a>, Amer. Math. Monthly, 72 (1965), 674; 73 (1966), 681682.
%e a(1)=a(2)=1 because it is not forbidden by the cubefree rule. But a(3) cannot be equal to 1, thus a(3)=2; Then a(4)=a(5)= 1, a(6)=2, a(7) = 1 but a(8)=2, because otherwise we would have the cube 112112112.
%o (R)
%o runlen< function(seq) {
%o n< length(seq)
%o if(n==1) return(c())
%o else {rl<c()
%o i<1
%o while(i < n) { k<1
%o while(i+k<=n) {
%o if(seq[i+k]!=seq[i]) break
%o else k<k+1}
%o if (i+k!=2) rl<c(rl, k)
%o i<i+k }
%o return(rl)}}
%o # following recursive function not optimized
%o isOK<function(x,seq) {
%o n<length(seq)
%o if(n<=1) return(1)
%o if(seq[n]==seq[n1]&seq[n1]==x) return(0)
%o rl<runlen(c(seq,x))
%o lrl<length(rl)
%o return(isOK(rl[lrl],rl[1:lrl1]))}
%o sequence<function(n) {
%o if(n<=0) return(c())
%o seq<c(1)
%o for(i in 2:n) {
%o if(isOK(1,seq)) seq<c(seq, 1)
%o else seq<c(seq, 2)}
%o return(cbind(c(1:n),seq))}
%Y Cf. A000002, A250006.
%K nonn
%O 1,3
%A _JeanChristophe HervĂ©_, Nov 10 2014
