%I #20 Mar 25 2023 09:41:20
%S -1,2402,-1,1552,287,388,417,1593,639,1136,1785,3090,2299,2341,1833,
%T 4052,2237,3012,3069,6843,5543,3000,5161,11722,6895,3578,8047,19739,
%U 9671,4156,8391,21424,15129,4734,8609,32690,19895,5312,10019,42710,21195,5890,12309,53764,34489,6468,19527,55911,23475
%N 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 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 (Python)
%o n = 2
%o KM = [(n, 1), (1, n), (-1, n), (-n, 1), (-n, -1), (-1, -n), (1, -n), (n, -1)]
%o def idx(loc):
%o i, j = loc
%o return (i + j - 1) * (i + j - 2) // 2 + j
%o def next_move(loc, visited):
%o i, j = loc
%o moves = [(i + io, j + jo) for io, jo in KM if i + io > 0 and j + jo > 0]
%o available = [m for m in moves if m not in visited]
%o return min(available, default=None, key=lambda x: idx(x))
%o def aseq():
%o locs = [[], []]
%o loc, s, turn, alst = [(1, 1), (1, 1)], {(1, 1)}, 0, [1]
%o m = next_move(loc[turn], s)
%o while m != None:
%o loc[turn], s, turn, alst = m, s | {m}, 0, alst + [idx(m)]
%o locs[turn] += [loc[turn]]
%o m = next_move(loc[turn], s)
%o if len(s) % 10000 == 0:
%o print('{steps} moves in'.format(steps = len(s)))
%o return alst
%o print(aseq())
%Y Cf. A323469, A323471, A352731.
%K sign
%O 1,2
%A _Andrew Smith_, Mar 30 2022