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-6 of 6 results.

A217010 Permutation of natural numbers arising from applying the walk of a square spiral (e.g., A214526) to the data of right triangular type-1 spiral (defined in A214230).

Original entry on oeis.org

1, 2, 13, 3, 5, 6, 7, 8, 9, 10, 12, 32, 61, 33, 14, 4, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 11, 31, 60, 98, 145, 99, 62, 34, 15, 17, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 28, 30, 59, 97, 144, 200, 265, 201, 146, 100, 63, 35, 16, 39, 71
Offset: 1

Views

Author

Alex Ratushnyak, Sep 23 2012

Keywords

Examples

			Triangular spiral (A214230) begins:
.
  56
   | \
  55  57
   |     \
  54  29  58
   |   | \   \
  53  28  30  59
   |   |     \   \
  52  27  11  31  60
   |   |   | \   \   \
  51  26  10  12  32  61
   |   |   |     \   \   \
  50  25   9   2  13  33  62
   |   |   |   | \   \   \   \
  49  24   8   1   3  14  34  63
   |   |   |         \   \   \   \
  48  23   7---6---5---4  15  35  64
   |   |                     \   \   \
  47  22--21--20--19--18--17--16  36  65
   |                                 \   \
  46--45--44--43--42--41--40--39--38--37  66
                                             \
  78--77--76--75--74--73--72--71--70--69--68--67
.
Square spiral (defining order in which elements are fetched) begins:
.
  49  26--27--28--29--30--31
   |   |                   |
  48  25  10--11--12--13  32
   |   |   |           |   |
  47  24   9   2---3  14  33
   |   |   |   |   |   |   |
  46  23   8   1   4  15  34
   |   |   |       |   |   |
  45  22   7---6---5  16  35
   |   |               |   |
  44  21--20--19--18--17  36
   |                       |
  43--42--41--40--39--38--37
		

Crossrefs

Programs

  • Python
    SIZE = 33       # must be 4k+1
    grid = [0] * (SIZE*SIZE)
    posX = posY = SIZE//2
    grid[posY*SIZE+posX]=1
    n = 2
    def walk(stepX, stepY, chkX, chkY):
      global posX, posY, n
      while 1:
        posX+=stepX
        posY+=stepY
        grid[posY*SIZE+posX]=n
        n+=1
        if grid[(posY+chkY)*SIZE+posX+chkX]==0:
            return
    while 1:
        walk(0, -1,  1,  1)    # up
        walk( 1, 1, -1,  0)    # right-down
        if posX==SIZE-1:
            break
        walk(-1, 0,  0, -1)    # left
    import sys
    grid2 = [0] * (SIZE*SIZE)
    posX = posY = SIZE//2
    grid2[posY*SIZE+posX]=1
    def walk2(stepX, stepY, chkX, chkY):
      global posX, posY
      while 1:
        a = grid[posY*SIZE+posX]
        if a==0:
            sys.exit(1)
        print(a, end=', ')
        posX+=stepX
        posY+=stepY
        grid2[posY*SIZE+posX]=1
        if grid2[(posY+chkY)*SIZE+posX+chkX]==0:
            return
    while posX:
        walk2(0, -1, 1, 0)    # up
        walk2(1, 0, 0, 1)     # right
        walk2(0, 1, -1, 0)    # down
        walk2(-1, 0, 0, -1)   # left

A217291 Permutation of natural numbers arising from applying the walk of right triangular type-1 spiral (defined in A214230) to the data of square spiral (e.g. A214526).

Original entry on oeis.org

1, 2, 4, 16, 5, 6, 7, 8, 9, 10, 27, 11, 3, 15, 35, 63, 36, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 51, 84, 52, 28, 12, 14, 34, 62, 98, 142, 99, 64, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 83, 124, 173, 125, 85, 53, 29, 13, 33, 61, 97, 141, 193, 253
Offset: 1

Views

Author

Alex Ratushnyak, Sep 30 2012

Keywords

Crossrefs

Programs

  • Python
    SIZE = 29    # must be 4k+1
    grid = [0] * (SIZE*SIZE)
    posX = posY = SIZE//2
    grid[posY*SIZE+posX]=1
    n = 2
    def walk(stepX, stepY, chkX, chkY):
      global posX, posY, n
      while 1:
        posX+=stepX
        posY+=stepY
        grid[posY*SIZE+posX]=n
        n+=1
        if grid[(posY+chkY)*SIZE+posX+chkX]==0:
            return
    while posX:
        walk(0, -1, 1, 0)    # up
        walk(1, 0, 0, 1)     # right
        walk(0, 1, -1, 0)    # down
        walk(-1, 0, 0, -1)   # left
    import sys
    grid2 = [0] * (SIZE*SIZE)
    posX = posY = SIZE//2
    grid2[posY*SIZE+posX]=1
    def walk2(stepX, stepY, chkX, chkY):
      global posX, posY
      while 1:
        a = grid[posY*SIZE+posX]
        if a==0:
            sys.exit(1)
        print(a, end=', ')
        posX+=stepX
        posY+=stepY
        grid2[posY*SIZE+posX]=1
        if grid2[(posY+chkY)*SIZE+posX+chkX]==0:
            return
    while 1:
        walk2(0, -1,  1,  1)    # up
        walk2( 1, 1, -1,  0)    # right-down
        if posX==SIZE-1:
            break
        walk2(-1, 0,  0, -1)    # left

A215468 Sum of the 8 nearest neighbors of n in a rotated-square spiral with positive integers.

Original entry on oeis.org

50, 62, 72, 86, 76, 84, 122, 88, 144, 104, 166, 120, 152, 160, 144, 218, 160, 168, 248, 184, 192, 278, 208, 216, 260, 268, 240, 248, 346, 264, 272, 280, 384, 296, 304, 312, 422, 328, 336, 344, 400, 408, 368, 376, 384, 506, 400, 408, 416, 424, 552, 440, 448, 456, 464, 598
Offset: 1

Views

Author

Alex Ratushnyak, Aug 11 2012

Keywords

Examples

			Spiral begins:
                     85
                     /
                    /
                  84 61-62
                  /  /    \
                 /  /      \
               83 60 41-42 63
               /  /  /    \  \
              /  /  /      \  \
            82 59 40 25-26 43 64
            /  /  /  /    \  \  \
           /  /  /  /      \  \  \
         81 58 39 24 13-14 27 44 65
         /  /  /  /  /    \  \  \  \
        /  /  /  /  /      \  \  \  \
      80 57 38 23 12  5--6 15 28 45 66
      /  /  /  /  /  /    \  \  \  \  \
     /  /  /  /  /  /      \  \  \  \  \
   79 56 37 22 11  4  1--2  7 16 29 46 67
     \  \  \  \  \  \   /  /  /  /  /  /
      \  \  \  \  \  \ /  /  /  /  /  /
      78 55 36 21 10  3  8 17 30 47 68
        \  \  \  \  \   /  /  /  /  /
         \  \  \  \  \ /  /  /  /  /
         77 54 35 20  9 18 31 48 69
           \  \  \  \   /  /  /  /
            \  \  \  \ /  /  /  /
            76 53 34 19 32 49 70
              \  \  \   /  /  /
               \  \  \ /  /  /
               75 52 33 50 71
                 \  \   /  /
                  \  \ /  /
                  74 51 72
                    \   /
                     \ /
                     73
.
The 8 nearest neighbors of 4 are 1,3,5,10,11,12,21,23, their sum is 86, so a(4)=86.
		

Crossrefs

Coordinates (but 0-based): A010751, A305258.

Programs

  • Python
    SIZE=17  # must be odd
    grid = [0] * (SIZE*SIZE)
    posX = posY = SIZE//2
    saveX = [0]* (SIZE*SIZE+1)
    saveY = [0]* (SIZE*SIZE+1)
    grid[posY*SIZE+posX]=1
    saveX[1]=posX
    saveY[1]=posY
    posX += 1
    grid[posY*SIZE+posX]=2
    saveX[2]=posX
    saveY[2]=posY
    n = 3
    def walk(stepX, stepY, chkX, chkY):
      global posX, posY, n
      while 1:
        posX+=stepX
        posY+=stepY
        grid[posY*SIZE+posX]=n
        saveX[n]=posX
        saveY[n]=posY
        n+=1
        if grid[(posY+chkY)*SIZE+posX+chkX]==0:
            return
    while posX!=SIZE-1:
        walk(-1,  1, -1, -1)    # down-left
        walk(-1, -1,  1, -1)    # up-left
        walk( 1, -1,  1,  0)    # up-right
        walk( 1,  0,  1,  1)    # right
        walk( 1,  1, -1,  1)    # down-right
    for s in range(1, n):
        posX = saveX[s]
        posY = saveY[s]
        i,j = grid[(posY-1)*SIZE+posX-1], grid[(posY-1)*SIZE+posX+1]
        u,v = grid[(posY+1)*SIZE+posX-1], grid[(posY+1)*SIZE+posX+1]
        if i==0 or j==0 or u==0 or v==0:
            break
        k = grid[(posY-1)*SIZE+posX  ] + grid[(posY+1)*SIZE+posX  ]
        k+= grid[ posY   *SIZE+posX-1] + grid[ posY   *SIZE+posX+1]
        print(i+j+u+v+k, end=' ')
    print()
    for y in range(SIZE):
        for x in range(SIZE):
            print('%3d' % grid[y*SIZE+x], end=' ')
        print()
    
  • Python
    def spiral(x, y):
        r = abs(x) + abs(y)
        return 1 + 2*r*r + (y-r if x > 0 else r-y)
    def A215468(n):
        x = A010751(n-1)
        y = A305258(n-1)
        return sum(spiral(x+i, y+j) for i in (-1, 0, 1) for j in (-1, 0, 1)
                   if (i, j) != (0, 0)) # David Radcliffe, Aug 05 2025

A214251 Sum of the eight nearest neighbors of n in a right triangular type-2 spiral with positive integers.

Original entry on oeis.org

62, 64, 69, 125, 94, 111, 170, 118, 105, 116, 169, 132, 131, 151, 192, 284, 217, 201, 206, 220, 258, 353, 265, 234, 227, 235, 243, 269, 349, 285, 275, 283, 291, 299, 328, 387, 515, 412, 378, 374, 382, 390, 398, 421, 477, 608, 484, 435, 419, 427, 435
Offset: 1

Views

Author

Alex Ratushnyak, Jul 08 2012

Keywords

Comments

Right triangular type-1 spiral (A214230): implements the sequence Up, Right-down, Left.
Right triangular type-2 spiral: Left, Up, Right-down.
Right triangular type-3 spiral (A214252): Right-down, Left, Up.

Examples

			Right triangular type-2 spiral begins:
67
66  68
65  37  69
64  36  38  70
63  35  16  39  71
62  34  15  17  40  72
61  33  14   4  18  41  73
60  32  13   3   5  19  42  74
59  31  12   2   1   6  20  43  75
58  30  11  10   9   8   7  21  44  76
57  29  28  27  26  25  24  23  22  45  77
56  55  54  53  52  51  50  49  48  47  46  78
The eight nearest neighbors of 5 are 1, 2, 3, 4, 18, 41, 19, 6. Their sum is a(5)=94.
		

Crossrefs

Cf. A214230.
Cf. A214252.

Programs

  • Python
    SIZE=29  # must be odd
    grid = [0] * (SIZE*SIZE)
    saveX = [0]* (SIZE*SIZE)
    saveY = [0]* (SIZE*SIZE)
    saveX[1] = saveY[1] = posX = posY = SIZE//2
    grid[posY*SIZE+posX]=1
    n = 2
    def walk(stepX, stepY, chkX, chkY):
      global posX, posY, n
      while 1:
        posX+=stepX
        posY+=stepY
        grid[posY*SIZE+posX]=n
        saveX[n]=posX
        saveY[n]=posY
        n+=1
        if posY==0 or grid[(posY+chkY)*SIZE+posX+chkX]==0:
            return
    while 1:
        walk(-1, 0,  0, -1)    # left
        walk(0, -1,  1,  1)    # up
        if posY==0:
            break
        walk( 1, 1, -1,  0)    # right-down
    for n in range(1, 92):
        posX = saveX[n]
        posY = saveY[n]
        k = grid[(posY-1)*SIZE+posX] + grid[(posY+1)*SIZE+posX]
        k+= grid[(posY-1)*SIZE+posX-1] + grid[(posY-1)*SIZE+posX+1]
        k+= grid[(posY+1)*SIZE+posX-1] + grid[(posY+1)*SIZE+posX+1]
        k+= grid[posY*SIZE+posX-1] + grid[posY*SIZE+posX+1]
        print(k, end=', ')

A214252 Sum of the eight nearest neighbors of n in a right triangular type-3 spiral with positive integers.

Original entry on oeis.org

62, 88, 63, 89, 76, 102, 170, 127, 126, 152, 223, 159, 140, 139, 159, 221, 175, 171, 179, 202, 249, 353, 274, 252, 254, 262, 279, 323, 430, 330, 293, 283, 291, 299, 307, 336, 425, 352, 339, 347, 355, 363, 371, 403, 468, 608, 493, 453, 446, 454, 462, 470, 478, 504
Offset: 1

Views

Author

Alex Ratushnyak, Jul 08 2012

Keywords

Comments

Right triangular type-1 spiral (A214230): implements the sequence Up, Right-down, Left.
Right triangular type-2 spiral (A214251): Left, Up, Right-down.
Right triangular type-3 spiral: Right-down, Left, Up.

Examples

			Right triangular type-3 spiral begins:
78
77  46
76  45  47
75  44  22  48
74  43  21  23  49
73  42  20   7  24  50
72  41  19   6   8  25  51
71  40  18   5   1   9  26  52
70  39  17   4   3   2  10  27  53
69  38  16  15  14  13  12  11  28  54
68  37  36  35  34  33  32  31  30  29  55
67  66  65  64  63  62  61  60  59  58  57  56
The eight nearest neighbors of 5 are 1, 3, 4, 17, 18, 19, 6, 8. Their sum is a(5)=76.
		

Crossrefs

Cf. A214230.
Cf. A214251.

Programs

  • Python
    SIZE=28  # must be even
    grid = [0] * (SIZE*SIZE)
    saveX = [0]* (SIZE*SIZE)
    saveY = [0]* (SIZE*SIZE)
    saveX[1] = saveY[1] = posX = posY = SIZE//2
    grid[posY*SIZE+posX]=1
    n = 2
    def walk(stepX, stepY, chkX, chkY):
      global posX, posY, n
      while 1:
        posX+=stepX
        posY+=stepY
        grid[posY*SIZE+posX]=n
        saveX[n]=posX
        saveY[n]=posY
        n+=1
        if posY==0 or grid[(posY+chkY)*SIZE+posX+chkX]==0:
            return
    while posY!=0:
        walk( 1, 1, -1,  0)    # right-down
        walk(-1, 0,  0, -1)    # left
        walk(0, -1,  1,  1)    # up
    for n in range(1, 92):
        posX = saveX[n]
        posY = saveY[n]
        k = grid[(posY-1)*SIZE+posX] + grid[(posY+1)*SIZE+posX]
        k+= grid[(posY-1)*SIZE+posX-1] + grid[(posY-1)*SIZE+posX+1]
        k+= grid[(posY+1)*SIZE+posX-1] + grid[(posY+1)*SIZE+posX+1]
        k+= grid[posY*SIZE+posX-1] + grid[posY*SIZE+posX+1]
        print(k, end=' ')

A214231 Sum of the four nearest neighbors of n in a right triangular type-1 spiral with positive integers.

Original entry on oeis.org

19, 35, 33, 52, 32, 33, 58, 41, 45, 58, 98, 75, 70, 74, 90, 127, 89, 81, 85, 89, 93, 136, 101, 105, 109, 113, 117, 139, 197, 156, 142, 146, 150, 154, 158, 183, 238, 182, 165, 169, 173, 177, 181, 185, 189, 250, 197, 201, 205, 209, 213, 217, 221, 225, 256, 332
Offset: 1

Views

Author

Alex Ratushnyak, Jul 08 2012

Keywords

Comments

Nearby numbers on diagonals are not counted as neighbors for this sequence.
Right triangular type-1 spiral implements the sequence Up, Right-down, Left.

Examples

			Right triangular spiral begins:
56
55  57
54  29  58
53  28  30  59
52  27  11  31  60
51  26  10  12  32  61
50  25   9   2  13  33  62
49  24   8   1   3  14  34  63
48  23   7   6   5   4  15  35  64
47  22  21  20  19  18  17  16  36  65
46  45  44  43  42  41  40  39  38  37  66
78  77  76  75  74  73  72  71  70  69  68  67
The four nearest neighbors of 3 are 1, 13, 14, 5. Their sum is a(3)=33.
		

Crossrefs

Cf. A214230 - sum of the 8 nearest neighbors, Python program.
Cf. A214227.
Showing 1-6 of 6 results.