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 A352731 #15 Mar 29 2023 09:20:24 %S A352731 -1,1378,-1,595,66,36,153,758,1185,78,1732,171,2510,2094,1407,253,630, %T A352731 210,780,2385,1326,300,1225,990,2800,406,3267,4333,4124,528,4309,741, %U A352731 5951,666,2701,903,30418,820,3321,1081,4186,990,8299,2775,4560,1176,4753,39951,5778 %N A352731 On a diagonally numbered square grid, with labels starting at 1, this is the number of the last cell that a (1,n) leaper reaches before getting trapped when moving to the lowest available unvisited square, or -1 if it never gets trapped. %C A352731 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 A323471). Once the (1,3) leaper reaches 39 it then performs the same set of 4 moves repeatedly, meaning that it never gets trapped. %o A352731 (Python) %o A352731 # reformatted by _R. J. Mathar_, 2023-03-29 %o A352731 class A352731(): %o A352731 def __init__(self,n) : %o A352731 self.n = n %o A352731 self.KM=[(n, 1), (1, n), (-1, n), (-n, 1), (-n, -1), (-1, -n), (1, -n), (n, -1)] %o A352731 @staticmethod %o A352731 def _idx(loc): %o A352731 i, j = loc %o A352731 return (i+j-1)*(i+j-2)//2 + j %o A352731 def _next_move(self,loc, visited): %o A352731 i, j = loc %o A352731 moves = [(i+io, j+jo) for io, jo in self.KM if i+io>0 and j+jo>0] %o A352731 available = [m for m in moves if m not in visited] %o A352731 return min(available, default=None, key=lambda x: A352731._idx(x)) %o A352731 def _aseq(self): %o A352731 locs = [[], []] %o A352731 loc, s, turn, alst = [(1, 1), (1, 1)], {(1, 1)}, 0, [1] %o A352731 m = self._next_move(loc[turn], s) %o A352731 while m != None: %o A352731 loc[turn], s, turn, alst = m, s|{m}, 0 , alst + [A352731._idx(m)] %o A352731 locs[turn] += [loc[turn]] %o A352731 m = self._next_move(loc[turn], s) %o A352731 if len(s)%100000 == 0: %o A352731 print(self.n,'{steps} moves in'.format(steps = len(s))) %o A352731 return alst %o A352731 def at(self,n) : %o A352731 if n == 1 or n == 3: %o A352731 return -1 %o A352731 else: %o A352731 return self._aseq()[-1] %o A352731 for n in range(1,40): %o A352731 a352731 = A352731(n) %o A352731 print(a352731.at(n)) %Y A352731 Cf. A323469, A323471, A352730. %K A352731 sign %O A352731 1,2 %A A352731 _Andrew Smith_, Mar 30 2022