This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
%I A383187 #13 May 20 2025 15:32:20 %S A383187 0,2,7,1,4,11,3,9,19,8,17,30,16,6,14,5,12,23,38,22,10,20,34,52,33,18, %T A383187 31,48,69,47,29,15,27,43,26,13,24,39,58,81,57,37,21,35,53,75,101,74, %U A383187 51,32,49,70,95,124,94,68,46,28,44,64,88,63,42,25,40,59,82,109,140,108,80,56,36,54,76 %N A383187 Diamond spiral number of the n-th point visited by the king moving on the two-dimensional grid always to the earliest unvisited point on the spiral, not immediately preceding or following on the spiral. %C A383187 A permutation of the nonnegative integers, whose restriction to the positive integers is also a permutation. See A383189 for the inverse permutation. %C A383187 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. %C A383187 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. %C A383187 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. %C A383187 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. %H A383187 M. F. Hasler, <a href="/A383187/b383187.txt">Table of n, a(n) for n = 0..999</a> %H A383187 M. F. Hasler, <a href="/A383187/a383187.png">Path plot of A383187</a>. (Green = starting point (0,0).) %o A383187 (Python) %o A383187 def diamond_number(z): %o A383187 x, y = int(z.real), int(z.imag); d = abs(x)+abs(y) %o A383187 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) %o A383187 def A383187(n): %o A383187 if not hasattr(A:=A383187, 'terms'): A.terms=[0]; A.pos=0; # A.track=[0] %o A383187 while len(A.terms) <= n: %o A383187 s, d = min((s, d) for d in (1, 1+1j, 1j, 1j-1, -1, -1-1j, -1j, 1-1j) if %o A383187 abs((s:=diamond_number(A.pos+d))-A.terms[-1]) > 1 and s not in A.terms) %o A383187 A.terms.append(s); A.pos += d; # A.track.append(A.pos) %o A383187 return A.terms[n] %Y A383187 Cf. A305258 (diamond spiral), A383185 (similar for a square spiral). %Y A383187 Cf. A383189 (inverse permutation). %K A383187 nonn,walk %O A383187 0,2 %A A383187 _M. F. Hasler_, May 12 2025