%I #13 Dec 27 2023 12:38:55
%S 0,1,2,3,4,5,6,7,9,10,8,11,12,13,14,15,20,21,18,22,16,17,19,23,24,25,
%T 26,27,28,29,30,31,43,44,40,45,37,38,41,46,33,34,32,35,36,39,42,47,49,
%U 50,48,51,52,53,54,55,56,57,58,59,60,61,62,63,90,91,86,92
%N Inverse permutation to A368431.
%H Rémy Sigrist, <a href="/A368432/b368432.txt">Table of n, a(n) for n = 0..8191</a>
%H Rémy Sigrist, <a href="/A368432/a368432.gp.txt">PARI program</a>
%H <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a>
%e A368431(42) = 46, so a(46) = 42.
%o (PARI) See Links section.
%o (Python)
%o from itertools import islice
%o from functools import reduce
%o def uniq(r): return reduce(lambda u, e: u if e in u else u+[e], r, [])
%o def A368431gen(): # generator of A368431
%o R, aset = [["0", "1"]], set()
%o while R:
%o r = R.pop(0)
%o for b in r:
%o d = int(b, 2)
%o if d not in aset: yield d; aset.add(d)
%o if len(r) > 1: R.append(uniq([r[k]+"0" for k in range(1, len(r))]))
%o R.append(uniq([r[0]+"0", r[0]+"1"] + [r[k]+"1" for k in range(1, len(r))]))
%o def agen(): # generator of terms
%o adict, n = dict(), 0
%o for i, k in enumerate(A368431gen()):
%o if k not in adict:
%o adict[k] = i
%o while n in adict: yield adict[n]; n += 1
%o print(list(islice(agen(), 70))) # _Michael S. Branicky_, Dec 24 2023
%Y Cf. A368431.
%K nonn,look,base
%O 0,3
%A _Rémy Sigrist_, Dec 24 2023