%I M0126 #52 Jun 08 2018 11:29:56
%S 0,1,1,2,1,3,1,1,3,2,1,6,3,2,1,3,1,1,6,3,2,4,1,1,3,2,1,3,1,6,4,2,1,2,
%T 4,3,1,8,3,2,1,6,3,2,1,3,1,1,6,3,2,4,1,1,3,2,1,3,1,30,6,3,2,4,1,1,3,2,
%U 1,3,1,6,4,2,1,2,4,3,1,8,3,2,1,6,3,2,1,3,1,1,6,3,2,4,1,1,3,2,1,3,1,6,4,2
%N The Sally sequence: the length of repetition avoided in A006345.
%C In the first 1000 terms, only patterns of lengths 0, 1, 2, 3, 4, 6, 8, 24, 30 and 108 are avoided. - _T. D. Noe_, Oct 14 2006
%C In the first 20000 terms, patterns of lengths 0, 1, 2, 3, 4, 5, 6, 7, 8, 16, 18, 24, 30, 108, 528, 552, 1298, 2752, 5876 are avoided. - _Robert Israel_, Jun 22 2015
%C In the first 10^6 terms, patterns of lengths 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 15, 16, 18, 24, 30, 36, 60, 72, 108, 318, 372, 414, 420, 444, 522, 528, 546, 552, 1280, 1292, 1298, 1632, 2620, 2752, 5876, 6203, 6218, 13912, 14312, 17220, 17580, 31532, 87650 are avoided. - _Ray Chandler_, Jun 24 2015
%D N. S. Hellerstein, personal communication to _N. J. A. Sloane_.
%D N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).
%H T. D. Noe, Robert Israel and Hugo van der Sanden, <a href="/A006346/b006346.txt">Table of n, a(n) for n = 1..50000</a> (1..1000 from T. D. Noe, 1001..20000 from Robert Israel)
%H N. Hellerstein, <a href="/A006345/a006345.pdf">Letter to N. J. A. Sloane, 1978</a>
%H N. Hellerstein, M. Gardner, & S. Kim, <a href="/A006345/a006345_1.pdf">Correspondence related to the Linus and Sally sequences, 1977</a>
%H N. J. A. Sloane, <a href="/A006345/a006345.html">Illustration of initial terms</a>
%H Eric Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/SallySequence.html">Sally Sequence.</a>
%p LDS:= proc(L)
%p local Cands, r, m;
%p Cands:= {$1..floor(nops(L)/2)};
%p r:= 0;
%p for m from 1 while nops(Cands) > 0 do
%p Cands:= select(c -> L[-m] = L[-c-m], Cands);
%p if min(Cands) = m then
%p r:= m;
%p Cands:= subs(m=NULL,Cands);
%p fi
%p od;
%p r
%p end proc:
%p A:= 1: B:= 0;
%p for n from 2 to 1000 do
%p a1:= LDS([A,1]);
%p a2:= LDS([A,2]);
%p if a1 < a2 then A:= A,1; B:= B, a2 else A:= A,2; B:= B, a1 fi;
%p od:
%p seq(B[i],i=1..1000); # _Robert Israel_, Jun 22 2015
%t max = 120;
%t LDS[L_] := Module[{Cands, r, m},
%t Cands = Range[Floor[Length[L]/2]];
%t r = 0;
%t For[m = 1, Length[Cands] > 0, m++,
%t Cands = Select[Cands, L[[-m]] == L[[-#-m]]&];
%t If[Min[Cands] == m, r = m;
%t Cands = ReplaceAll[Cands, m -> Nothing]]
%t ];
%t r];
%t A = {1}; B = {0};
%t For[n = 2, n <= max, n++,
%t a1 = LDS[Append[A, 1]];
%t a2 = LDS[Append[A, 2]];
%t If[a1 < a2,
%t AppendTo[A, 1]; AppendTo[B, a2],
%t AppendTo[A, 2]; AppendTo[B, a1]
%t ]
%t ];
%t Table[B[[i]], {i, 1, max}] (* _Jean-François Alcover_, Jun 08 2018, after _Robert Israel_'s Maple program *)
%Y Cf. A006345.
%K nonn,nice,easy,look
%O 1,4
%A _N. J. A. Sloane_
%E More terms from _Naohiro Nomoto_, May 21 2001
|