OFFSET
0,2
COMMENTS
A permutation of the nonnegative integers, whose restriction to the positive integers is also a permutation. See A383189 for the inverse permutation.
By "king" we simply mean a cursor that can move to any of the 8 nearest (von Neumann) neighbors, as the king moves in the game of chess.
Analog of A383185 (which uses the square spiral or shells of given sup norm) for the diamond spiral (or shells of given taxicab or L1-norm) as defined, e.g., in A305258. There are less grid points having a given L1 norm, so, in this sense, the diamond spiral numbering yields a "finer" measure of the distance from the origin than the square spiral numbering.
Instead of introducing a wall that has to be crossed (as in A383185), it is here sufficient to forbid the immediately following or preceding point in order to avoid a trivial sequence (0, 1, 2, ...) of numbers.
The actual trajectory of the king is however relatively uninteresting: The resulting path consists in a clockwise square spiral (centered at (1/2, 1/2)) with transition to the next shell on the negative y-axis, cf. the "path plot" given in links.
LINKS
M. F. Hasler, Table of n, a(n) for n = 0..999
M. F. Hasler, Path plot of A383187. (Green = starting point (0,0).)
PROG
(Python)
def diamond_number(z):
x, y = int(z.real), int(z.imag); d = abs(x)+abs(y)
return 2*d*(d-1)+((x if y<0 else d+y)if x>0 else 2*d-x if y>0 else 3*d-y)
def A383187(n):
if not hasattr(A:=A383187, 'terms'): A.terms=[0]; A.pos=0; # A.track=[0]
while len(A.terms) <= n:
s, d = min((s, d) for d in (1, 1+1j, 1j, 1j-1, -1, -1-1j, -1j, 1-1j) if
abs((s:=diamond_number(A.pos+d))-A.terms[-1]) > 1 and s not in A.terms)
A.terms.append(s); A.pos += d; # A.track.append(A.pos)
return A.terms[n]
CROSSREFS
KEYWORD
nonn,walk
AUTHOR
M. F. Hasler, May 12 2025
STATUS
approved
