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.

Previous Showing 21-30 of 34 results. Next

A383185 Number of the square visited by a king moving on a spirally numbered board always to the lowest available unvisited square, when a wall delimiting the spiral must be crossed on each move.

Original entry on oeis.org

0, 3, 13, 2, 10, 1, 7, 21, 6, 18, 4, 14, 32, 12, 28, 11, 27, 9, 23, 8, 22, 44, 20, 40, 19, 5, 17, 37, 16, 34, 15, 33, 59, 31, 57, 30, 54, 29, 53, 85, 51, 25, 47, 24, 46, 76, 45, 75, 43, 73, 42, 70, 41, 69, 39, 67, 38, 66, 36, 62, 35, 61, 95, 60, 94, 58, 92, 56, 88, 55, 87, 127, 86, 52, 26
Offset: 0

Views

Author

M. F. Hasler, May 12 2025

Keywords

Comments

The board is numbered following a square spiral starting with 0 at the origin (where the king is at n = 0) and delimited by a wall that must be crossed on each move:
.
16 15 14 13 12 | .
,-----------. | .
17 | 4 3 2 |11 | .
| ,--- | | .
18 | 5 | 0 1 |10 | .
| '-------' | .
19 | 6 7 8 9 | .
`---------------' .
20 21 22 23 24 25
.
A line drawn from the center of the starting square to the center of the ending square must pass through a wall on each move. A move that would just touch a wall without passing through the wall (e.g., 0 to 2) is not permissible. Equivalently, the king can't move from a square labeled k to a square labeled k +- 1 or k +- 2, i.e., |a(n)-a(n+1)| > 2 for all n.
This sequence is a permutation of the nonnegative integers, see A383186 for the inverse permutation. The king's walk indeed fills the 2D grid with an initial segment S0 of 24 moves, followed by rings R(r), r >= 1, which consist of three shells S1(r), S2(r) and S3(r), each of which corresponds to a tour around the center. Each ring R(r) starts with the move number n = 48 r^2 - 16 r + 1 = (25, 147, 365, ...) to the square at position P(r) = (2-3r, 3r-3) = ((-1,0), (-4,3), (-7,6), ...), and contains a perfectly well defined sequence of 96 r + 26 grid points following a precise sequence of pattern given in full detail on the wiki page provided in the links section.

Examples

			For n = 1, a(1) = 3 because moving from 0 to 1 or 2 does not pass through a wall.
		

Crossrefs

Cf. A375925 (the same with indices and numbers of squares starting at 1).
Cf. A383186 (inverse permutation).
Cf. A316328 (knight's path), A033638, A316667 (trapped knight), A336038 (trapped king), A335856 (trapped king preferably moving to prime numbers).

Programs

  • Python
    def square_number(z): return int(4*y**2-y-x if (y := z.imag) >= abs(x := z.real)
        else 4*x**2-x-y if -x>=abs(y) else (4*y-3)*y+x if -y>=abs(x) else (4*x-3)*x+y)
    def A383185(n):
        if not hasattr(A:=A383185, 'terms'): A.terms=[0]; A.pos=0; A.path=[0]
        while len(A.terms) <= n:
            s,d = min((s,d) for d in (1, 1+1j, 1j, 1j-1, -1, -1-1j, -1j, 1-1j) if
                abs((s:=square_number(A.pos+d))-A.terms[-1]) > 2 and s not in A.terms)
            A.terms.append(s); A.pos += d; A.path.append(A.pos)
        return A.terms[n]
    import matplotlib.pyplot as plt # this and below to plot the trajectory
    plt.plot([z.real for z in A383185.path], [z.imag for z in A383185.path])
    plt.show()

A351043 Lexicographically earliest non-extendable Racetrack trajectory (using von Neumann neighborhood) on spiral on infinite square grid.

Original entry on oeis.org

0, 1, 9, 24, 46, 45, 21, 6, 4, 15, 33, 32, 12, 11, 10, 8, 7, 5, 16, 36, 63, 97, 96, 60, 13, 27, 50, 80, 119, 165, 164, 116, 75, 41, 68, 66, 64, 99, 141, 140, 138, 93, 55, 86, 84, 49, 79, 78, 76, 43, 69, 104, 102, 100, 143, 193, 192, 190, 137, 57, 54, 52, 25
Offset: 0

Views

Author

Pontus von Brömssen, Jan 30 2022

Keywords

Comments

The car starts at square 0 and thereafter moves, according to the rules of Racetrack with von Neumann neighborhood (see A351042), to the lowest numbered unvisited square. The spiral numbering is described in A316328. After 146 steps, the car cannot move to any unvisited square, so the sequence is finite with 147 terms.
The position of the car after n steps is (A174344(a(n)+1), A274923(a(n)+1)). - Pontus von Brömssen, Jan 30 2025

Crossrefs

A380812 Sequence of x-coordinates of the lexicographically earliest (according to the spiral numbering of the square grid; see comments) infinite Racetrack trajectory (using von Neumann neighborhood) on the square grid.

Original entry on oeis.org

0, 1, 2, 2, 1, 0, -1, -1, -1, -1, 0, 1, 2, 2, 2, 1, 0, -1, -2, -3, -3, -2, -1, 0, 1, 3, 4, 4, 4, 3, 2, 1, -1, -3, -4, -4, -4, -4, -3, -2, 0, 2, 4, 5, 5, 4, 3, 2, 0, -2, -4, -5, -5, -5, -5, -4, -3, -1, 1, 3, 4, 4, 3, 2, 1, -1, -3, -5, -6, -6, -5, -3, 0, 3, 6, 8
Offset: 0

Views

Author

Pontus von Brömssen, Feb 05 2025

Keywords

Comments

The car starts at the origin and thereafter moves, according to the rules of Racetrack with von Neumann neighborhood (see A351042 or Wikipedia link), to the unvisited square that has the lowest spiral number, provided that it is possible to extend the trajectory to an infinite one. The spiral numbering is described in A316328.
The trajectory in A351043 is defined in a similar way, but it does not backtrack when it gets stuck, so it is finite, ending after 146 steps. The trajectory here is identical to the trajectory in A351043 for the first 144 steps.

Examples

			In the 144th step, the car moves from (-9,-8) to (-6,-6) (a(144) = A380813(144) = -6). A priori, the next possible positions (ordered by increasing spiral number) are (-3,-3), (-4,-4), (-3,-4), (-2,-4), and (-3,-5). Of these, (-3,-3) has already been visited (after the 103rd step), so the next choice is (-4,-4). From that position, however, the car is forced to move to (-2,-2) (all other alternatives have already been visited), and from (-2,-2) there are no available positions not already visited (so the trajectory in A351043 ends there). The next option (-3,-4) is also a dead end, but from (-2,-4) it is possible to continue forever, so a(145) = -2 and A380813(145) = -4.
		

Crossrefs

Cf. A174344, A316328, A351042, A351043, A380813 (y-coordinates), A380814.

Formula

a(n) = A174344(A351043(n)+1) for n <= 144.

A383183 Square spiral numbers of the n-th grid point visited by a king always moving to the unvisited point labeled with the smallest possible prime or else composite number.

Original entry on oeis.org

0, 2, 3, 5, 7, 23, 47, 79, 48, 24, 8, 1, 11, 13, 31, 29, 53, 27, 9, 10, 26, 25, 49, 83, 50, 51, 52, 28, 12, 30, 54, 55, 89, 131, 179, 129, 87, 127, 85, 84, 124, 173, 229, 293, 227, 169, 223, 167, 119, 80, 81, 82, 122, 120, 121, 168, 170, 171, 123, 172, 228, 292, 226, 224, 225, 287, 359, 439
Offset: 0

Views

Author

M. F. Hasler, May 13 2025

Keywords

Comments

The infinite 2D grid is labeled along a square spiral as shown in A316328, starting with 0 at the origin (0,0), where the n-th shell contains the 8n points with sup norm n, as follows:
.
16--15--14--13--12 :
| | :
17 4---3---2 11 28
| | | | |
18 5 0---1 10 27
| | | |
19 6---7---8---9 26
| |
20--21--22--23--24--25
.
The cursor is moving like a chess king to the von Neumann neighbor not visited earlier and labeled with the smallest prime number if possible, otherwise with the smallest possible composite number.
After the 171th move, the cursor is trapped in the point (3,0) labeled a(171) = 33. All eight neighbors were then already visited earlier, so the king has no more any possible move.

Examples

			From the starting point (0,0) labeled a(0) = 0, the king can reach the point (1,1) labeled 2, which is the smallest possible prime number, so a(1) = 2.
Then the king can reach (1,0) labeled 3 which is the next smaller prime number, so a(2) = 3. From there it can go to (-1,0) labeled 5 = a(3), and then to (0,-1) labeled a(4) 7 = a(4). From there, the only available prime number is 23 = a(5) at (1,-2).
The king continues in that south-east direction, before walking in north-east direction and then back and further south-east up to and beyond the point (10,-10). Then it goes back in the opposite north-west direction up to (-8,7) and (-5, 8), before heading to the point (3,0) where it gets stuck.
		

Crossrefs

Cf. A383184 (the same with "diamond spiral" numbering).
Cf. A383185 (similar with |a(n)-a(n+1)| > 2 instead of the prime number condition).
Cf. A335856 (same with the square spiral and indices starting at 1).
Cf. A316328 (knight path on square spiral numbered board).

Programs

  • Python
    from sympy import isprime # = A010051
    def square_number(z): return int(4*y**2-y-x if (y := z.imag) >= abs(x := z.real)
        else 4*x**2-x-y if -x>=abs(y) else (4*y-3)*y+x if -y>=abs(x) else (4*x-3)*x+y)
    def A383183(n, moves=(1, 1+1j, 1j, 1j-1, -1, -1-1j, -1j, 1-1j)):
        if not hasattr(A:=A383183, 'terms'): A.terms=[0]; A.pos=0; A.path=[0]
        while len(A.terms) <= n:
            try: _,s,z = min((1-isprime(s), s, z) for d in moves if
                         (s := square_number(z := A.pos+d)) not in A.terms)
            except ValueError:
                raise IndexError(f"Sequence has only {len(A.terms)} terms")
            A.terms.append(s); A.pos = z; A.path.append(z)
        return A.terms[n]
    A383183(999) # gives IndexError: Sequence has only 172 terms
    A383183.terms # shows the full sequence; append [:N] to show only N terms
    import matplotlib.pyplot as plt # this and following to plot the path:
    plt.plot([z.real for z in A383183.path], [z.imag for z in A383183.path])
    plt.show()

A306308 Table read by rows: the end square loops for a trapped knight moving on an infinitely large 2-dimensional spirally numbered board starting from any square.

Original entry on oeis.org

404, 3328, 2666, 1338, 736, 1535, 2168, 406, 2444, 2945, 2245, 605, 684, 2663, 2312, 3323, 935, 910
Offset: 1

Views

Author

Scott R. Shannon, Feb 05 2019

Keywords

Comments

Construction: with a knight (a (1,2)-leaper) on an infinite spiral numbered board moving to the lowest numbered unvisited square (see A316884), start the knight on any square and continue moving it until it is trapped. Then start an entirely new sequence starting the knight at the same square at which it was previously trapped. Continue this process until the square at which the knight is trapped has occurred previously, indicating an end square loop. All starting squares for the knight on the infinite board will eventually lead to the knight path falling into one of the 3 end square loops listed here.
As the total number of squares in which the knight can be trapped is finite (see A306291), we expect there to be a finite number of end square loops - in theory, only those values (1518 is all) need to be checked when searching for an end square loop. However, all starting square values up to 302500 have been checked to determine into which of the 3 found loops the knight eventually falls. The 13-member loop with 406 as its lowest number is found to be the dominant loop, with about 89.6% of all initial starting squares going to it. The other 10.4% mostly go to the 3-member loop with 404 as its lowest number, with a decreasingly small remainder going to the 2-member loop with 910 as it lowest number. The attached 3-color image showing the start-value-to-loop mapping shows that the pattern of starting square to end square loops becomes very regular away from the center of the board.

Examples

			The 3 end square loops are:
1: 404, 3328, 2666
2: 1338, 736, 1535, 2168, 406, 2444, 2945, 2245, 605, 684, 2663, 2312, 3323
3: 935, 910
Starting the knight from the square 1 leads to the first 3-member loop after two iterations: the sequence of end squares is 2084, 404, 3328, 2666, 404, ... . Starting from the square 2 leads to the second (13-member) loop after ten iterations: the sequence is 711, 632, 4350, 3727, 3610, 7382, 2411, 4632, 4311, 1338, ... . The third (2-member) loop is not seen until the knight starts from square 284, the sequence being entered after two iterations via 1168, 935, 910, 935, ... .
		

Crossrefs

A337170 Squares visited by knight moves on a diagonally back and forth numbered board and moving to the lowest available unvisited square at every step.

Original entry on oeis.org

1, 8, 4, 2, 13, 3, 6, 9, 11, 19, 5, 7, 26, 16, 14, 31, 15, 18, 12, 21, 24, 10, 23, 33, 39, 20, 22, 34, 25, 17, 28, 47, 43, 29, 27, 32, 40, 35, 37, 53, 57, 36, 58, 52, 38, 55, 80, 76, 56, 54, 59, 51, 42, 30, 45, 48, 62, 70, 44, 46, 64, 49, 41, 72, 60, 50, 63
Offset: 1

Views

Author

Sander G. Huisman, Jan 28 2021

Keywords

Comments

Board is numbered as follows:
1 3 4 10 11 .
2 5 9 12 . .
6 8 13 19 . .
7 14 18 . . .
15 17 . . . .
16 . . . . .
This sequence is finite: At step 343 square 276 is visited, after which there are no unvisited squares within one knight move.

Crossrefs

Programs

  • Mathematica
    ClearAll[ShowRoute,MakeMove,FindSequence]
    knightjump=Select[Tuples[Range[-2,2],2],Norm[#]==Sqrt[5]&];
    ShowRoute[output_Association]:=Module[{colors},colors=(ColorData["Rainbow"]/@Subdivide[Length[output["Coordinates"]]-1.0]);
    Graphics[{Line[output["Coordinates"],VertexColors->colors],Disk[Last@output["Coordinates"],0.2]}]]
    MakeMove[spiral_Association,visited_List]:=Module[{poss,hj},poss=Table[Last[Last[visited]]+hj,{hj,knightjump}];
    poss=DeleteMissing[{spiral[#],#}&/@poss,1,\[Infinity]];
    poss=Select[poss,FreeQ[visited[[All,2]],Last[#]]&];
    If[Length[poss]>0,First[TakeSmallestBy[poss,First,1]],Missing[]]]
    FindSequence[start_:{0,0},grid_]:=Module[{positions,j,next},positions={{grid[start],start}};
    PrintTemporary[Dynamic[j]];
    Do[next=MakeMove[grid,positions];
    If[next=!=Missing[],AppendTo[positions,next],Break[];],{j,\[Infinity]}];
    <|"Coordinates"->positions[[All,2]],"Indices"->positions[[All,1]]|>]
    grid=ResourceFunction["LatticePointsArrangement"]["DiagonalZigZagEastQ4",10000];
    grid=Association[MapIndexed[#1->#2[[1]]&,grid]];
    ShowRoute[fs=FindSequence[{0,0},grid]]
    fs
    fs["Indices"]
    ListPlot[fs["Indices"]]

A375925 Squares visited by a king moving on a walled, spirally numbered board, where a wall must be jumped on each move, always to the lowest available unvisited square.

Original entry on oeis.org

1, 4, 14, 3, 11, 2, 8, 22, 7, 19, 5, 15, 33, 13, 29, 12, 28, 10, 24, 9, 23, 45, 21, 41, 20, 6, 18, 38, 17, 35, 16, 34, 60, 32, 58, 31, 55, 30, 54, 86, 52, 26, 48, 25, 47, 77, 46, 76, 44, 74, 43, 71, 42, 70, 40, 68, 39, 67, 37, 63, 36, 62, 96, 61, 95, 59, 93
Offset: 1

Views

Author

Sameer Khan, Sep 03 2024

Keywords

Comments

The board is numbered with the following walled, square spiral:
.
17 16 15 14 13 | .
------------- | .
18 | 5 4 3 |12 | .
| ----- | | .
19 | 6 | 1 2 |11 | .
| --------- | .
20 | 7 8 9 10 | .
----------------- .
21 22 23 24 25 26
.
The walls mark the boundary of the spiral.
A line drawn from the center of the starting square of a king move to the center of the ending square must pass through a wall. The king jumps over that wall. Some moves would just touch a wall without passing through the wall (e.g. 1 to 3). Such moves are not permissible.
The rules imply that the king cannot move from a square labeled k in the spiral to a square labeled k +- 1 or k +- 2.
Comment from M. F. Hasler, May 08 2025 (Start)
The sequence appears to be a permutation of the positive integers. The path drawn by Kevin Ryde shows the quasi-periodic structure of the trajectory and may lead to a formal proof.
However, it would be more natural to start the path at the origin, at a square labeled n = 0 (to which the king never moves). Then the sequence would conjecurally be a permutation of the nonnegative integers. This also leads to a more natural numbering for the squares in terms of the x,y coordinates - compare the Python function "square_number()". See A383185. (End) [Comment edited by N. J. A. Sloane, May 14 2025 following discussion with Kevin Ryde.]

Examples

			For n = 2, a(2) = 4 because moving to 2 or 3 does not pass through a wall.
		

Crossrefs

Cf. A033638, A316667 (trapped knight), A336038 (trapped king).
Cf. A383185 (zero-indexed variant), A316328 (knight's path).

Programs

  • Python
    def square_number(z): return int(4*y**2-y-x if (y := z.imag) >= abs(x := z.real)
        else 4*x**2-x-y if -x>=abs(y) else (4*y-3)*y+x if -y>=abs(x) else (4*x-3)*x+y)
    def A375925(n):
        if not hasattr(A:=A375925, 'terms'): A.terms=[1]; A.pos=0
        while len(A.terms) < n:
            s,d = min((s,d) for d in (1, 1+1j, 1j, 1j-1, -1, -1-1j, -1j, 1-1j) if
                abs((s:=1+square_number(A.pos+d))-A.terms[-1]) > 2 and s not in A.terms)
            A.terms.append(s); A.pos += d
        return A.terms[n-1] # M. F. Hasler, May 07 2025

Formula

a(n) = A383185(n-1)+1. - M. F. Hasler, May 12 2025

Extensions

Entry revised by N. J. A. Sloane, May 12 2025

A383190 a(2n) and a(2n+1) are the square spiral numbers of the position on which the (n+1)th domino is placed, when tiling the plane by placing the dominos always as near as possible to the origin and so that no two dominos share a long side. Inverse permutation of A383191.

Original entry on oeis.org

0, 1, 3, 4, 5, 6, 7, 22, 2, 11, 8, 9, 10, 27, 14, 13, 18, 17, 15, 16, 19, 20, 21, 44, 23, 46, 12, 29, 24, 25, 33, 34, 39, 40, 45, 76, 28, 53, 32, 31, 38, 37, 26, 51, 35, 36, 41, 42, 43, 74, 47, 78, 52, 85, 60, 59, 68, 67, 61, 62, 69, 70, 75, 114, 77, 116, 30, 55, 48, 49, 54, 87, 58, 57, 66, 65
Offset: 0

Views

Author

M. F. Hasler, Apr 18 2025

Keywords

Comments

"As near as possible to the origin" means that one end of the domino is placed on the free grid point nearest to the origin for the Euclidean distance, and in case of a tie, earliest counter-clockwise, starting to the right. (I.e., on the complex plane, the lexico-earliest (|z|, arg z) with 0 <= arg z < tau = 6.283185...) The other end of the domino will be placed on a free grid point to the north, south, east or west of the first end, also nearest possible to the origin, but so that the domino is not side-by-side sharing a long side with another domino. Each domino is represented by two consecutive integers (2n, 2n+1): (0, 1), (2, 3), etc.
The sequence is obtained by listing the "square spiral number" (cf. A316328) corresponding to the position of the number n (i.e., the first half of the (n/2+1)th domino for even n, and the second half of the (n+1)/2-th domino for odd n.
This sequence is a permutation of the nonnegative integers.
The inverse permutation A383191 is obtained by reading these integers along the plane filling square spiral, starting at the origin, then one step to the right, then one step up, etc.

Examples

			The first domino (0, 1) is placed on the origin and the square to its right.
The second domino (2, 3) is placed above the origin (nearest free point coming first counter-clockwise), oriented to the left (since going to the right would make it side-by-side with the first domino, which is forbidden).
Then the third domino (4, 5) is placed left to the origin, going downwards (using the free point closest to the origin).
The fourth domino (6, 7) is placed below the origin, going downwards (since going to the right would make it parallel to the first domino).
Then the free points nearest to the origin are to its lower right and to its upper right. The upper right is preferred since it comes first counter-clockwise (starting to the right). The domino (8, 9) is placed sidewards, again because the other end upwards) would come later in counter-clockwise sense.
Then the domino (10, 11) is placed to the lower right, also sideways because vertically it would be side-by-side with (6, 7).
The first 16 dominoes are placed as follows, where the numbers (2n-2, 2n-1) represent the two ends of the n-th domino, and t
|
|    19==18  14==15  26==27
|
|    17   3===2   8===9           The sequence is obtained by listing the square
|    ||                           spiral number corresponding to the position of
|    16   4   0===1  12==13       the numbers 0, 1, 2, 3...: 0 for 0, 1 for 1,
|         ‖                       3 (square spiral number for position (x=0, y=1)
|    20   5   6  10==11           where 2 is placed, 4 for the position of 3,
|    ||       ‖                   5, 6, 7 for the position of 4, 5, 6; then
|    21  22   7  24  28==29       22 for the position (x=0, y=-2) of 7, 2 for 8, ...
|        ||      ||
|        23      25
|
We see that all dominoes in the upper right half plane are placed horizontally, and in the lower left half they are placed vertically.
		

Crossrefs

Cf. A383191 (inverse permutation), A316328 (knight tour with illustration of the square spiral), A174344 (square spiral, but clockwise).

Programs

  • Python
    class A383190: # use A383190(n) or a=A383190(); a[n]; print(a); for x in a: ...
        border, grid, terms = {0}, {}, []
        neighbors = (1, 1+1j, 1j, 1j-1, -1, -1-1j, -1j, 1-1j)
        def _str_(self): #"ASCII representation of (filled part of) the plane."
            X = sorted({z.real for z in self.grid}); L = len(str(len(self.terms)))+1
            return "\n".join("".join(f"{self.grid.get(x+y*1j,'')!s:{L}}" for x in X)
                             for y in sorted({z.imag for z in self.grid}, reverse=1))
        def _new_(cls, n: int | None = None) -> int | object:
            """Return a(n) or the sequence object if no n is given."""
            return super()._new_(cls) if n is None else super()._new_(cls)(n)
        def _call_(self, n: int | None = None) -> int | object:
            """Return a(n) or the sequence object if no n is given."""
            return self if n is None else self.extend(upto=n) or self.terms[n]
        def _getitem_(self, n: int | slice) -> int | list:
            return self(n) if isinstance(n, int) else [self(n) for n in
                range(*n.indices(max(len(self.terms), abs(n.stop or 0))))]
        def extend(self, upto=None):
            "Place new domino(s) on the grid, as 'close' as possible to the origin."
            while len(self.terms) <= (upto or (upto := len(self.terms))):
                self.fill(pos := min(self.border, key = self.distance))
                self.fill(self.second(pos))
        def distance(self, pos):
            "Return (abs(pos), arg(pos)), where 0 <= arg < τ = 2π."
            return abs(pos), atan2(pos.imag, pos.real) % tau
        def fill(self, pos):
            """Fill the next available number into grid[pos], increment, and
            update border = {free cells that are neighbor to a filled cell}."""
            self.grid[pos] = len(self.terms); self.border.remove(pos)
            self.border |= {pos+N for N in self.neighbors if pos+N not in self.grid}
            self.terms += [int(4*y**2-y-x if (y:=pos.imag)>=abs(x:=pos.real) else
             4*x**2-x-y if -x>=abs(y) else (4*y-3)*y+x if -y>=abs(x) else(4*x-3)*x+y)]
        def second(self,pos):
            """Find the second cell adjacent to 'pos' so that the domino is oriented
            according the rules (closest to origin but no domino side-by-side)."""
            return min((pos+dir for dir in(1, 1j, -1, -1j) if pos+dir not in self.grid
                and all(self.grid.get(p+dir, -1) != self.grid.get(p, -1) ^ 1
                        for p in (pos+1j*dir, pos-1j*dir) ) ), key = self.distance)
    from math import atan2, tau
    print(A383190()[:50])
    print(A383190()) # displays the grid filled so far

A383191 a(n) is the number on the n-th position on the square spiral on the plane tiled with dominoes always placed nearest to the origin and so that no two dominos share a long side. Inverse permutation of A383190.

Original entry on oeis.org

0, 1, 8, 2, 3, 4, 5, 6, 10, 11, 12, 9, 26, 15, 14, 18, 19, 17, 16, 20, 21, 22, 7, 24, 28, 29, 42, 13, 36, 27, 66, 39, 38, 30, 31, 44, 45, 41, 40, 32, 33, 46, 47, 48, 23, 34, 25, 50, 68, 69, 76, 43, 52, 37, 70, 67, 108, 73, 72, 55, 54, 58, 59, 80, 81, 75, 74, 57, 56, 60, 61, 84, 85, 86, 49, 62
Offset: 0

Views

Author

M. F. Hasler, Apr 18 2025

Keywords

Comments

Each domino is represented by two consecutive integers (2k, 2k+1): (0, 1), (2, 3), etc.
"Nearest to the origin" means that one end of the domino (i.e., the number 2k) is placed on the free grid point nearest to the origin for the Euclidean distance, and in case of a tie, the earliest in counter-clockwise sense, starting to the right. (I.e., on the complex plane, the lexico-earliest (|z|, arg z) with 0 <= arg z < tau = 6.283185...) The other end of the domino will be placed on a free grid point to the north, south, east or west of the first end, also nearest possible to the origin, but so that the domino is not side-by-side sharing a long side with another domino.
The sequence is obtained by reading these integers along the plane filling square spiral starting at the origin, then one step to the right, then one step up, etc.
This sequence is a permutation of the nonnegative integers. The inverse permutation A383190 is obtained if to each number "filled in" we associate the square spiral number corresponding to its position on the grid. See A316328 (and also A174344) for an illustration of the square spiral numbers.

Examples

			The first domino (0, 1) is placed on the origin and the square to its right.
The second domino (2, 3) is placed above the origin (nearest free point coming first counter-clockwise), oriented to the left (since going to the right would place it side-by-side with the first domino, which is forbidden).
Then the third domino (4, 5) is placed left to the origin, going downwards (using the free point closest to the origin).
The fourth domino (6, 7) is placed below the origin, going downwards (since going to the right would make it parallel to the first domino).
Then the free points nearest to the origin are to its lower right and to its upper right. The upper right is preferred since it comes first counter-clockwise (starting to the right). The domino (8, 9) is placed sidewards, again because the other end upwards) would come later in counter-clockwise sense.
Then the domino (10, 11) is placed to the lower right, also sideways because vertically it would be side-by-side with (6, 7).
The first 16 dominoes are placed as follows, where the numbers (2n-2, 2n-1) represent the two ends of the n-th domino:
|
|    19==18  14==15  26==27
|
|    17   3===2   8===9
|    ||
|    16   4   0===1  12==13       The sequence is obtained by reading the numbers
|         ‖                       along the square spiral: starting at the origin
|    20   5   6  10==11           (0), go 1 right (1), 1 up (8), 2 left (2 and 3),
|    ||       ‖                   2 down (4 and 5), 3 right (6, 10, 11), 3 up
|    21  22   7  24  28==29       (12, 9, 26) 4 left (15, 14, 18, 19), etc.
|        ||      ||
|        23      25
|
We see that all dominoes in the upper right half plane are placed horizontally, and in the lower left half they are placed "vertically".
		

Crossrefs

Cf. A383190 (inverse permutation), A316328 (knight tour with illustration of square spiral), A174344 (square spiral, but clockwise), A316667 (square spiral starting with 1).

Programs

  • Python
    class A383191(A383190): # use A383191(n) or a=A383191(); a(n); a[m:n]; print(a)
        def _call_(self, n: int) -> int:
            "Return A383191(n)."
            if isinstance(n, int) and n >= 0:
                while n not in self.terms: self.extend()
                return self.terms.index(n) # this is the inverse permutation of 'terms'
            if n is None: return self # because A383191() => A383190(n=None) => a(n)
            raise ValueError(f"Expected non-negative index n, got {n = !r}.")
    A383191()[:50]   # list [a(0) .. a(49)]
    print(A383191()) # displays the grid filled so far (same as A383190)

A306421 End squares for a trapped knight moving on a spirally numbered 2D grid where each square can be visited n times.

Original entry on oeis.org

2084, 124561, 1756923, 21375782, 48176535, 128322490, 196727321, 230310289, 606217402, 2856313870, 244655558, 659075420, 586292888, 1646774611, 1018215514, 719687377, 564513339, 2779028614, 298995630, 1641747842, 414061107, 1467655587, 584309414, 1584716050
Offset: 1

Views

Author

Scott R. Shannon, Feb 14 2019

Keywords

Comments

For a knight (a (1,2) leaper) starting at square 1 and moving on a spirally numbered 2D grid to the lowest-numbered available square at each step (see A316667), a(n) is the number of the square at which the knight is trapped if it is allowed to visit each square no more than n times -- the knight is not trapped until each of the 8 surrounding squares to which it can leap has been visited n times. The choice of the square to which it goes at each step is determined solely by the square with the lowest spiral number, as long as it has been visited fewer than n times. This is an infinite sequence, although end squares beyond a(35) are currently unknown.

Examples

			For n = 1, the knight becomes trapped at square 2084 (see A316667). The following table gives the corresponding values for n = 1 through 35:
.
     | Square at which | Number of steps
     |  the knight is  | before the
   n |     trapped     | knight is trapped
  ---+-----------------+--------------
   1 |         2084    |          2016 (A316667)
   2 |       124561    |        244273
   3 |      1756923    |       4737265
   4 |     21375782    |      98374180
   5 |     48176535    |     258063291
   6 |    128322490    |     836943142
   7 |    196727321    |    1531051657
   8 |    230310289    |    1897092533
   9 |    606217402    |    5253106114
  10 |   2856313870    |   27296872250
  11 |    244655558    |    2772304666
  12 |    659075420    |    8437814958
  13 |    586292888    |    7875951360
  14 |   1646774611    |   24511621133
  15 |   1018215514    |   15493169264
  16 |    719687377    |   11643899003
  17 |    564513339    |    9593491769
  18 |   2779028614    |   49835086546
  19 |    298995630    |    5734502340
  20 |   1641747842    |   33370972720
  21 |    414061107    |    8844741817
  22 |   1467655587    |   32843399937
  23 |    584309414    |   13583967470
  24 |   1584716050    |   37945957450
  25 |   2544445470    |   62083869640
  26 |   4796115990    |  125967045044
  27 |   1881606731    |   51291895045
  28 |   1321212795    |   37635024035
  29 |   6693611092    |  196994700434
  30 |    687619472    |   19985943874
  31 |   1495794139    |   45392651369
  32 |   6677258413    |  213836002227
  33 |   6451059544    |  219770103702
  34 |   7958333435    |  277128625469
  35 |  13924943879    |  485324576539
		

Crossrefs

Previous Showing 21-30 of 34 results. Next