%I #16 Apr 15 2021 15:24:19
%S 0,1,2,4,3,5,13,6,11,7,12,8,10,9,14,40,15,38,16,39,17,34,20,37,18,32,
%T 22,33,21,35,19,36,23,31,24,29,25,30,26,28,27,41,121,42,119,43,120,44,
%U 115,47,118,45,113,49,114,48,116,46,117,50,103,59,112,51,101
%N Lexicographically earliest sequence of distinct nonnegative integers such that for any n >= 0, the digits "-1" in the balanced ternary representation of a(n) correspond to digits "+1" in that of a(n+1).
%C This sequence is a permutation of the nonnegative integers (with inverse A343313):
%C - we can always extend the sequence with a member of A003462 sufficiently large,
%C - so the sequence is infinite and unbounded,
%C - once we have a k-digit number and before introducing a number with more than k digits, we must use A003462(k),
%C - so we have infinitely many terms of A003462 in this sequence,
%C - for any m with k digits, we have infinitely many terms of A003462 > m in the sequence, each of these terms can be followed by m, so m must eventually appear.
%C Apparently:
%C - the sequence preserves the number of digits in balanced ternary representation (A134021),
%C - fixed points correspond to 0 and A007051.
%H Rémy Sigrist, <a href="/A343312/b343312.txt">Table of n, a(n) for n = 0..9842</a>
%H Rémy Sigrist, <a href="/A343312/a343312.png">Scatterplot of the sequence for n = 0..3^9</a>
%H Rémy Sigrist, <a href="/A343312/a343312.gp.txt">PARI program for A343312</a>
%H <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a>
%F A343229(a(n)) AND A343228(a(n+1)) = A343228(a(n+1)) (where AND denotes the bitwise AND operator).
%e The first terms, alongside their balanced ternary representation (with "T" instead of digits "-1"), are:
%e n a(n) bter(a(a))
%e -- ---- ----------
%e 0 0 0
%e 1 1 1
%e 2 2 1T
%e 3 4 11
%e 4 3 10
%e 5 5 1TT
%e 6 13 111
%e 7 6 1T0
%e 8 11 11T
%e 9 7 1T1
%e 10 12 110
%e 11 8 10T
%e 12 10 101
%e 13 9 100
%e 14 14 1TTT
%e 15 40 1111
%e 16 15 1TT0
%e 17 38 111T
%o (PARI) See Links section.
%Y Cf. A003462, A007051, A134021, A343228, A343229, A343313 (inverse).
%K nonn,base,look
%O 0,3
%A _Rémy Sigrist_, Apr 11 2021