login
List run lengths of digits different from '3'. Lexicographically first such sequence of nonnegative numbers with no repeated terms.
8

%I #13 Dec 23 2024 14:53:44

%S 1,3,0,2,4,33,5,6,30,7,8,9,31,10,11,12,14,15,16,17,18,19,20,21,22,24,

%T 25,26,27,32,28,29,34,40,41,13,42,44,45,46,47,48,49,50,51,52,54,55,56,

%U 57,58,35,59,60,61,36,62,64,65,23,66,67,68,69,43,70,71,72,74,75,76,77,78,79,80,81,82,84,85,86,53

%N List run lengths of digits different from '3'. Lexicographically first such sequence of nonnegative numbers with no repeated terms.

%C In the concatenation of all terms of this sequence, "13024335630...", consider the digits '3' as delimiters of chunks of other digits, "1", "024", "", "56", .... The lengths of these chunks are given by the terms of the sequence. At any point, the next term is the smallest number not occurring earlier and not leading to a contradiction.

%H Eric Angelini, <a href="https://web.archive.org/web/*/http://list.seqfan.eu/oldermail/seqfan/2015-August/015191.html">To reach the next "1"</a>, SeqFan list, August 10, 2015.

%e The sequence starts with a(1) = 1 digits different from '3'. (It is not possible to start with a 0 because this would require to start with a chunk of 0 digits different from '3', i.e., with a digit 3, contradiction.)

%e Then, after the initial a(1) = 1, must follow a digit '3', viz., a(2) = 3.

%e This implies that the next 3 digits must be different from '3': a(3) = 0, a(4) = 2 and a(5) = 4 are the smallest possible choices.

%e Then must follow a chunk of a(3) = 0 digits different from '3', otherwise said, two consecutive digits 3, whence a(6) = 33.

%e Then follow a(4) = 2 other digits, a(7) = 5 and a(8) = 6, before the next '3' in a(9) = 30, etc.

%o (PARI) A261163(n=99,d=3,a=1,p=0,u=[-1],r=u)={for(n=2,n, print1(a","); p+=#digits(a)+!a; r=concat(r,r[#r]+a+1); while(#r>1&&r[1]<p,r=r[2..-1]); u=setunion(u,[a]);while(#u>1&&u[2]==u[1]+1,u=u[2..-1]); for(k=u[1]+1,9e9,setsearch(u,k)&&next; if(r[1] >= p+#dk=if(k,digits(k),[0]), setsearch(Set(dk),d)&&next, for(i=1,#dk,(dk[i]==d)==!setsearch(r,p+i-1)&&next(2))); a=k;next(2));error);a}

%K nonn,base

%O 1,2

%A _Eric Angelini_ and _M. F. Hasler_, Aug 10 2015