OFFSET
1,2
COMMENTS
Start with this sequence, "shuffle" as in A007063 and the sequence reappears in the diagonal of the array. Terms are transformed from A307536 to this lexicofirst version by replacing the first and all subsequent occurrences of any term > all preceding terms by k+1, where k is the greatest (transformed) term seen so far. The records of this sequence is the natural numbers, A000027, starting point of the original Kimberling exclusion array.
LINKS
D. Gale, Tracking the Automatic Ant: And Other Mathematical Explorations, ch. 5, p. 27. Springer, 1998.
C. Kimberling, Problem 1615, Crux Mathematicorum, Vol. 17 (2) 44 1991 and Vol. 18, March 1992, pp. 82-83.
EXAMPLE
PROG
(PARI)
A(z) = {x=z; y=z; xx=2*x-4; while (y<=xx, x--; xx-=2; if (bittest(y, 0)==1, y=x+((y+1)>>1), y=x-(y>>1))); return(x+y-1); } \\ A007063
B(z) = {a=z; n=1; while (a!=n, if (a<n, a=2*(n-a), a>2*n, a--, a=2*(a-n)-1); n++); return(a); } \\ A006852
addgroup(group, n, fixed, v) = {my(ok = 1, m=v[n]); while(ok, listput(group, m); if (m==n, ok=0; break); if (m > #v, ok=0; break); n = m; m = v[n]; ); group; }
makegroup(n, fixed, va, vb) = {my(group = List()); listput(group, n); group = addgroup(group, n, fixed, va); group = addgroup(group, n, fixed, vb); listsort(group, 1); Vec(group); }
setgroup(v, n, group) = {my(gmin = vecmin(group)); for (i=1, #group, if ((group[i] <= #v) && !v[n], v[n] = gmin); ); v; }
lista() = {nn = 200; nout = 90; va = vector(nn, k, A(k)); vb = vector(nn, k, B(k)); vc = vector(nn); fixed = List(); for (n = 1, nn, if (va[n] == n, listput(fixed, n)); ); fixed = Vec(fixed); for (n=1, nn, group = makegroup(n, fixed, va, vb); vc = setgroup(vc, n, group); ); vector(nout, k, vc[k]); } \\ A307536
earliest(v) = {my(m = Map(), val=1); for (i=1, #v, if (!mapisdefined(m, v[i]), mapput(m, v[i], val); val++); ); apply(x->mapget(m, x), v); }
earliest(lista()) \\ Michel Marcus, Jun 14 2019
CROSSREFS
KEYWORD
nonn
AUTHOR
David James Sycamore and Lars Blomberg, Apr 29 2019
STATUS
approved