login
A330091
Inverse permutation to A329303.
2
0, 1, 2, 3, 4, 5, 6, 7, 8, 11, 10, 9, 12, 13, 14, 15, 16, 23, 22, 19, 18, 21, 20, 17, 24, 27, 26, 25, 28, 29, 30, 31, 32, 47, 46, 39, 38, 45, 44, 35, 34, 41, 42, 37, 36, 43, 40, 33, 48, 55, 54, 51, 50, 53, 52, 49, 56, 59, 58, 57, 60, 61, 62, 63, 64, 95, 94, 79
OFFSET
0,3
COMMENTS
If the run lengths in binary expansion of n are (r(1), ..., r(w)), then the run lengths in binary expansion of a(n) are (r(1), r(w), r(2), r(w-1), ...); this corresponds to a "milk shuffle".
EXAMPLE
A329303(43) = 45, hence a(45) = 43.
PROG
(PARI) torl(n) = { my (rr=[]); while (n, my (r=valuation(n+(n%2), 2)); rr = concat(r, rr); n\=2^r); rr }
unshuffle(v) = { my (w=vector(#v), o=0, e=#v+1); for (k=1, #v, w[k]=v[if (k%2, o++, e--)]); w }
fromrl(rr) = { my (v=0); for (k=1, #rr, v = (v+(k%2))*2^rr[k]-(k%2)); v }
a(n) = fromrl(unshuffle(torl(n)))
CROSSREFS
Cf. A329303.
Sequence in context: A377193 A376839 A329303 * A175948 A348268 A269853
KEYWORD
nonn,base
AUTHOR
Rémy Sigrist, Dec 01 2019
STATUS
approved