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 A352730 #20 Mar 25 2023 09:41:20 %S A352730 -1,2402,-1,1552,287,388,417,1593,639,1136,1785,3090,2299,2341,1833, %T A352730 4052,2237,3012,3069,6843,5543,3000,5161,11722,6895,3578,8047,19739, %U A352730 9671,4156,8391,21424,15129,4734,8609,32690,19895,5312,10019,42710,21195,5890,12309,53764,34489,6468,19527,55911,23475 %N A352730 On a diagonally numbered square grid, with labels starting at 1, this is the number of steps that a (1,n) leaper makes before getting trapped when moving to the lowest available unvisited square, or -1 if it never gets trapped. %C A352730 A (1,2) leaper is a chess knight. (1,1) and (1,3) leapers both never get trapped. This is understandable for the (1,1) leaper but not so much for the (1,3) which does get trapped on the spirally numbered board (see A323469). Once the (1,3) leaper reaches 39 it then performs the same set of 4 moves repeatedly, meaning that it never gets trapped. %o A352730 (Python) %o A352730 n = 2 %o A352730 KM = [(n, 1), (1, n), (-1, n), (-n, 1), (-n, -1), (-1, -n), (1, -n), (n, -1)] %o A352730 def idx(loc): %o A352730 i, j = loc %o A352730 return (i + j - 1) * (i + j - 2) // 2 + j %o A352730 def next_move(loc, visited): %o A352730 i, j = loc %o A352730 moves = [(i + io, j + jo) for io, jo in KM if i + io > 0 and j + jo > 0] %o A352730 available = [m for m in moves if m not in visited] %o A352730 return min(available, default=None, key=lambda x: idx(x)) %o A352730 def aseq(): %o A352730 locs = [[], []] %o A352730 loc, s, turn, alst = [(1, 1), (1, 1)], {(1, 1)}, 0, [1] %o A352730 m = next_move(loc[turn], s) %o A352730 while m != None: %o A352730 loc[turn], s, turn, alst = m, s | {m}, 0, alst + [idx(m)] %o A352730 locs[turn] += [loc[turn]] %o A352730 m = next_move(loc[turn], s) %o A352730 if len(s) % 10000 == 0: %o A352730 print('{steps} moves in'.format(steps = len(s))) %o A352730 return alst %o A352730 print(aseq()) %Y A352730 Cf. A323469, A323471, A352731. %K A352730 sign %O A352730 1,2 %A A352730 _Andrew Smith_, Mar 30 2022