%I #13 Dec 27 2023 12:33:46
%S 1,2,3,5,6,4,7,12,13,10,14,8,9,11,15,27,28,24,29,21,22,25,30,17,18,16,
%T 19,20,23,26,31,58,59,54,60,50,51,55,61,44,45,42,46,48,52,56,62,36,37,
%U 34,38,32,33,35,39,40,41,43,47,49,53,57,63,121,122,116
%N Inverse permutation to A368427.
%H Rémy Sigrist, <a href="/A368428/b368428.txt">Table of n, a(n) for n = 1..8191</a>
%H Rémy Sigrist, <a href="/A368428/a368428.gp.txt">PARI program</a>
%H <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a>
%e A368427(67) = 107, so a(107) = 67.
%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 A368427gen(): # generator of terms of A368427
%o R = [["1"]]
%o while R:
%o r = R.pop(0)
%o yield from map(lambda b: int(b, 2), r)
%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(), 1
%o for i, k in enumerate(A368427gen(), 1):
%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(), 66))) # _Michael S. Branicky_, Dec 24 2023
%Y Cf. A368427.
%K nonn,look,base
%O 1,2
%A _Rémy Sigrist_, Dec 24 2023
|