cp's OEIS Frontend

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.

A375925 Squares visited by a king moving on a walled, spirally numbered board, where a wall must be jumped on each move, always to the lowest available unvisited square.

This page as a plain text file.
%I A375925 #65 May 14 2025 22:17:04
%S A375925 1,4,14,3,11,2,8,22,7,19,5,15,33,13,29,12,28,10,24,9,23,45,21,41,20,6,
%T A375925 18,38,17,35,16,34,60,32,58,31,55,30,54,86,52,26,48,25,47,77,46,76,44,
%U A375925 74,43,71,42,70,40,68,39,67,37,63,36,62,96,61,95,59,93
%N A375925 Squares visited by a king moving on a walled, spirally numbered board, where a wall must be jumped on each move, always to the lowest available unvisited square.
%C A375925 The board is numbered with the following walled, square spiral:
%C A375925 .
%C A375925   17  16  15  14  13 | .
%C A375925      -------------   | .
%C A375925   18 | 5   4   3 |12 | .
%C A375925      |   -----   |   | .
%C A375925   19 | 6 | 1   2 |11 | .
%C A375925      |   ---------   | .
%C A375925   20 | 7   8   9  10 | .
%C A375925      ----------------- .
%C A375925   21  22  23  24  25  26
%C A375925 .
%C A375925 The walls mark the boundary of the spiral.
%C A375925 A line drawn from the center of the starting square of a king move to the center of the ending square must pass through a wall. The king jumps over that wall. Some moves would just touch a wall without passing through the wall (e.g. 1 to 3). Such moves are not permissible.
%C A375925 The rules imply that the king cannot move from a square labeled k in the spiral to a square labeled k +- 1 or k +- 2.
%C A375925 Comment from _M. F. Hasler_, May 08 2025 (Start)
%C A375925 The sequence appears to be a permutation of the positive integers. The path drawn by _Kevin Ryde_ shows the quasi-periodic structure of the trajectory and may lead to a formal proof.
%C A375925 However, it would be more natural to start the path at the origin, at a square labeled n = 0 (to which the king never moves). Then the sequence would conjecurally be a permutation of the nonnegative integers. This also leads to a more natural numbering for the squares in terms of the x,y coordinates - compare the Python function "square_number()". See A383185. (End) [Comment edited by _N. J. A. Sloane_, May 14 2025 following discussion with _Kevin Ryde_.]
%H A375925 Sameer Khan, <a href="/A375925/b375925.txt">Table of n, a(n) for n = 1..100</a>
%H A375925 Kevin Ryde, <a href="/A375925/a375925_1.pdf">Path Plot</a>
%F A375925 a(n) = A383185(n-1)+1. - _M. F. Hasler_, May 12 2025
%e A375925 For n = 2, a(2) = 4 because moving to 2 or 3 does not pass through a wall.
%o A375925 (Python)
%o A375925 def square_number(z): return int(4*y**2-y-x if (y := z.imag) >= abs(x := z.real)
%o A375925     else 4*x**2-x-y if -x>=abs(y) else (4*y-3)*y+x if -y>=abs(x) else (4*x-3)*x+y)
%o A375925 def A375925(n):
%o A375925     if not hasattr(A:=A375925, 'terms'): A.terms=[1]; A.pos=0
%o A375925     while len(A.terms) < n:
%o A375925         s,d = min((s,d) for d in (1, 1+1j, 1j, 1j-1, -1, -1-1j, -1j, 1-1j) if
%o A375925             abs((s:=1+square_number(A.pos+d))-A.terms[-1]) > 2 and s not in A.terms)
%o A375925         A.terms.append(s); A.pos += d
%o A375925     return A.terms[n-1] # _M. F. Hasler_, May 07 2025
%Y A375925 Cf. A033638, A316667 (trapped knight), A336038 (trapped king).
%Y A375925 Cf. A383185 (zero-indexed variant), A316328 (knight's path).
%K A375925 nonn
%O A375925 1,2
%A A375925 _Sameer Khan_, Sep 03 2024
%E A375925 Entry revised by _N. J. A. Sloane_, May 12 2025