A328909 Knight's tour on spirally numbered infinite board, when the knight always jumps on the unvisited square closest to the origin, first according to the sup-norm, then 2-norm, then number of the square: a(n) = number of square visited at move n.
0, 9, 2, 5, 8, 3, 6, 1, 4, 7, 10, 13, 28, 31, 14, 11, 26, 23, 44, 19, 22, 43, 40, 17, 34, 37, 18, 15, 32, 29, 52, 25, 46, 21, 42, 69, 20, 39, 16, 33, 12, 27, 24, 45, 74, 41, 68, 103, 38, 35, 60, 93, 30, 53, 84, 49, 78, 115, 160, 75, 116, 47, 76, 113, 72, 107, 150, 67, 36, 61, 94, 57, 54, 85, 50, 79, 82
Offset: 0
Examples
The squares are numbered as in the spiral given in A174344 (upside down to get a counterclockwise spiral, but this is irrelevant here). The knight starts at a(0) = 0 with coordinates (0, 0). It jumps to a(1) = 9 with coordinates (2, -1): all 8 available squares (+-2, +-1) and (+-1, +-2) are at the same sup-norm and Euclidean distance from the origin, but square number 9 has the smallest number.
Links
- M. F. Hasler, Table of n, a(n) for n = 0..25108
- M. F. Hasler, Knight tours, OEIS wiki, Nov. 2019
Crossrefs
Programs
-
PARI
{local(coords(n, m=sqrtint(n), k=m\/2)=if(m<=n-=4*k^2, [n-3*k, -k], n>=0, [-k, k-n], n>=-m, [-k-n, k], [k, 3*k+n]), U=[]/*used squares*/, K=vector(8, i, [(-1)^(i\2)<<(i>4), (-1)^i<<(i<5)])/* knight moves*/, pos(x,y)=if(y>=abs(x), 4*y^2-y-x, -x>=abs(y),4*x^2-x-y, -y>=abs(x),(4*y-3)*y+x, (4*x-3)*x+y), t(x, p=pos(x[1],x[2]))=if(p<=U[1]||setsearch(U, p), oo, [vecmax(abs(x)), norml2(x), p]), nxt(p, x=coords(p))=vecsort(apply(K->t(x+K), K))[1][3]); my(A=List(0)/*list of positions*/); for(n=1, oo, U=setunion(U, [A[n]]); while(#U>1&&U[2]==U[1]+1, U=U[^1]); iferr(listput(A, nxt(A[n])), E, break)); print("Index of last term: ", #A-1); A328909(n)=A[n+1];} \\ To compute the infinite extension of the sequence, set en upper limit to the for() loop and replace "break" by listput(A, A[n-1])
Comments