OFFSET
1,2
COMMENTS
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.
PROG
(Python)
# reformatted by R. J. Mathar, 2023-03-29
class A352731():
def __init__(self, n) :
self.n = n
self.KM=[(n, 1), (1, n), (-1, n), (-n, 1), (-n, -1), (-1, -n), (1, -n), (n, -1)]
@staticmethod
def _idx(loc):
i, j = loc
return (i+j-1)*(i+j-2)//2 + j
def _next_move(self, loc, visited):
i, j = loc
moves = [(i+io, j+jo) for io, jo in self.KM if i+io>0 and j+jo>0]
available = [m for m in moves if m not in visited]
return min(available, default=None, key=lambda x: A352731._idx(x))
def _aseq(self):
locs = [[], []]
loc, s, turn, alst = [(1, 1), (1, 1)], {(1, 1)}, 0, [1]
m = self._next_move(loc[turn], s)
while m != None:
loc[turn], s, turn, alst = m, s|{m}, 0 , alst + [A352731._idx(m)]
locs[turn] += [loc[turn]]
m = self._next_move(loc[turn], s)
if len(s)%100000 == 0:
print(self.n, '{steps} moves in'.format(steps = len(s)))
return alst
def at(self, n) :
if n == 1 or n == 3:
return -1
else:
return self._aseq()[-1]
for n in range(1, 40):
a352731 = A352731(n)
print(a352731.at(n))
CROSSREFS
KEYWORD
sign
AUTHOR
Andrew Smith, Mar 30 2022
STATUS
approved