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.

Showing 1-1 of 1 results.

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.

Original entry on oeis.org

-1, 2402, -1, 1552, 287, 388, 417, 1593, 639, 1136, 1785, 3090, 2299, 2341, 1833, 4052, 2237, 3012, 3069, 6843, 5543, 3000, 5161, 11722, 6895, 3578, 8047, 19739, 9671, 4156, 8391, 21424, 15129, 4734, 8609, 32690, 19895, 5312, 10019, 42710, 21195, 5890, 12309, 53764, 34489, 6468, 19527, 55911, 23475
Offset: 1

Views

Author

Andrew Smith, Mar 30 2022

Keywords

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 A323469). Once the (1,3) leaper reaches 39 it then performs the same set of 4 moves repeatedly, meaning that it never gets trapped.

Crossrefs

Programs

  • Python
    n = 2
    KM = [(n, 1), (1, n), (-1, n), (-n, 1), (-n, -1), (-1, -n), (1, -n), (n, -1)]
    def idx(loc):
        i, j = loc
        return (i + j - 1) * (i + j - 2) // 2 + j
    def next_move(loc, visited):
        i, j = loc
        moves = [(i + io, j + jo) for io, jo in 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: idx(x))
    def aseq():
        locs = [[], []]
        loc, s, turn, alst = [(1, 1), (1, 1)], {(1, 1)}, 0, [1]
        m = next_move(loc[turn], s)
        while m != None:
            loc[turn], s, turn, alst = m, s | {m}, 0, alst + [idx(m)]
            locs[turn] += [loc[turn]]
            m = next_move(loc[turn], s)
            if len(s) % 10000 == 0:
                print('{steps} moves in'.format(steps = len(s)))
        return alst
    print(aseq())
Showing 1-1 of 1 results.