%I
%S 2,20,6,10,8,11,60,5,13,4,3,19,52,16,24,14,9,27,12,1,17,36,28,15,21,
%T 43,18,23,34,61,37,25,30,68,100,22,31,7,32,56,47,33,26,35,39,38,41,44,
%U 48,73,59,42,49,130,64,40,53,62,51,46,45,58,101,55,70,57,86
%N Lexicographically earliest selfdescribing sequence of distinct terms such that, when we read digit after digit from the left to the right, the nth digit of the sequence is duplicated at the digitposition a(n). After all duplications are done, the resulting sequence is itself.
%H Lars Blomberg, <a href="/A308387/b308387.txt">Table of n, a(n) for n = 1..7000</a>
%H Eric Angelini, <a href="https://cinquantesignes.blogspot.com/2019/03/twoselfdescribingsequencesfor.html">Two selfdescribing sequences</a>.
%e The sequence starts with 2,20,6,10,8,11,60,...
%e The 1st digit (2) is duplicated at position 2 in the sequence, as a(1) = 2 (this new 2 is visible in 20);
%e The 2nd digit (2) is duplicated at position 20 in the sequence, as a(2) = 20 (this new 2 is visible in 52);
%e The 3rd digit (0) is duplicated at position 6 in the sequence, as a(3) = 6 (this new 0 is visible in 10);
%e The 4th digit (6) is duplicated at position 10 in the sequence, as a(4) = 10 (this new 6 is visible in 60);
%e The 5th digit (1) is duplicated at position 8 in the sequence, as a(5) = 8 (this new 1 is visible in 11, first digit); etc.
%e The duplication rule is: a(n) cannot command the duplication of one of its own digits  else the lexicographically first sequence would simply be 1, 2, 3, 4, 5, ... where every digit is "duplicated" on itself. We see with this counterexample that the sequence cannot start with a(1) = 1 as this digit 1 would be duplicated on itself; but a(1) = 2 is ok as there is an unused integer a(2) that starts with the duplicated 2 (here, 20, as 20 is the smallest unused term starting with 2); etc.
%e Why is a(3) = 6?
%e We must remember that a(3) = k means that the 3rd digit of the sequence is duplicated at digitposition k (counting digit after digit from the beginning); as the 3rd digit of the sequence is 0 (the 0 visible in 20), we cannot have a(3) = 1, which would be a contradiction (the 1st digit is a 2 and not a 0): so this start is impossible: 2,20,1,...
%e a(3) = 2 is impossible too, as there is already a term 2 in the sequence;
%e a(3) = 3 is impossible, as this would duplicate 0 on itself (forbidden);
%e a(3) = 4 is impossible too, see: 2,20,4,... The 3rd digit, 0, cannot be duplicated in digitposition 4 as this position is already occupied by 4 itself!
%e a(3) = 5 is impossible too, because no term can have a leading 0, see: 2,20,5,0,... and the try 2,20,10,... is lexicographically worse then the solution coming now;
%e But a(3) = 6 works: 2,20,6,.0 (the dot is a free space, available for a digit that will stick to the 0); thus a(4) = 10, the smallest unused integer that produces no contradiction (this 10, being the 4th term of the sequence, commands the duplication of the 4th digit (6) at the digitposition 10 in the sequence; this is ok for the moment: 2,20,6,10,...6...
%e Etc.
%Y A347691 is the inverse.
%Y Cf. A308386 (illustrates the same idea, but with letters instead of digits).
%K base,nonn,changed
%O 1,1
%A _Eric Angelini_, May 23 2019
