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.

A217014 Permutation of natural numbers arising from applying the walk of a square spiral (e.g. A214526) to the data of triangular horizontal-last spiral (defined in A214226).

Original entry on oeis.org

1, 7, 22, 8, 2, 3, 4, 6, 20, 42, 21, 44, 75, 45, 23, 9, 11, 12, 13, 14, 15, 5, 19, 41, 71, 109, 72, 43, 74, 113, 160, 114, 76, 46, 24, 10, 28, 29, 30, 31, 32, 33, 34, 16, 18, 40, 70, 108, 154, 208, 155, 110, 73, 112, 159, 214
Offset: 1

Views

Author

Alex Ratushnyak, Sep 23 2012

Keywords

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(1,  1, -1,  0)    # down-right
        walk(-1, 0,  1, -1)    # left
        walk(-1, 0,  1, -1)    # left
        if posX<2:
            break
        walk(1, -1,  1,  1)    # up-right
    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, 0)    # up
        walk2(1, 0, 0, 1)     # right
        walk2(0, 1, -1, 0)    # down
        walk2(-1, 0, 0, -1)   # left

A217295 Permutation of natural numbers arising from applying the walk of triangular horizontal-last spiral (defined in A214226) to the data of square spiral (e.g. A214526).

Original entry on oeis.org

1, 5, 6, 7, 22, 8, 2, 4, 16, 36, 17, 18, 19, 20, 21, 44, 75, 45, 23, 9, 11, 3, 15, 35, 63, 99, 64, 37, 38, 39, 40, 41, 42, 43, 74, 113, 160, 114, 76, 46, 24, 10, 28, 12, 14, 34, 62, 98, 142, 194, 143, 100, 65, 66, 67, 68, 69, 70, 71, 72, 73, 112, 159, 214, 277
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(1,  1, -1,  0)    # down-right
        walk2(-1, 0,  1, -1)    # left
        walk2(-1, 0,  1, -1)    # left
        if posX<2:
            break
        walk2(1, -1,  1,  1)    # up-right

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

Original entry on oeis.org

53, 88, 78, 125, 85, 84, 125, 97, 108, 143, 223, 168, 158, 169, 201, 284, 208, 183, 179, 187, 210, 281, 226, 219, 227, 235, 261, 314, 430, 339, 311, 310, 318, 326, 346, 396, 515, 403, 360, 347, 355, 363, 371, 379, 411, 509, 427, 411, 419, 427, 435, 443, 451, 486, 557
Offset: 1

Views

Author

Alex Ratushnyak, Jul 08 2012

Keywords

Comments

Right triangular type-1 spiral implements the sequence Up, Right-down, Left.
Right triangular type-2 spiral (A214251): Left, Up, Right-down.
Right triangular type-3 spiral (A214252): Right-down, Left, Up.
A140064 -- rightwards from 1: 3,14,34...
A064225 -- leftwards from 1: 8,24,49...
A117625 -- upwards from 1: 2,12,31...
A006137 -- downwards from 1: 6,20,43...
A038764 -- left-down from 1: 7,22,46...
A081267 -- left-up from 1: 9,26,52...
A081589 -- right-up from 1: 13, 61, 145...
9*x^2/2 - 19*x/2 + 6 -- right-down from 1: 5,18,40...

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 eight nearest neighbors of 3 are 1, 2, 13, 33, 14, 4, 5, 6. Their sum is a(3)=78.
		

Crossrefs

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(0, -1,  1,  1)    # up
        if posY==0:
            break
        walk( 1, 1, -1,  0)    # right-down
        walk(-1, 0,  0, -1)    # left
    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=', ')

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

A214250 Sum of the eight nearest neighbors of n in a triangular "horizontal-first" spiral with positive integers.

Original entry on oeis.org

56, 80, 108, 84, 132, 92, 84, 96, 128, 200, 152, 144, 236, 160, 172, 204, 284, 212, 188, 184, 192, 200, 208, 232, 280, 384, 304, 280, 280, 288, 428, 304, 312, 320, 340, 388, 500, 396, 356, 344, 352, 360, 368, 376, 384, 392, 400, 432, 496, 632, 520, 480, 472, 480
Offset: 1

Views

Author

Alex Ratushnyak, Jul 08 2012

Keywords

Examples

			Spiral begins:
__ __ __ __ __ __ __ 57
__ __ __ __ __ __ 56 31 58
__ __ __ __ __ 55 30 13 32 59
__ __ __ __ 54 29 12  3 14 33 60
__ __ __ 53 28 11  2  1  4 15 34 61
__ __ 52 27 10  9  8  7  6  5 16 35 62
__ 51 26 25 24 23 22 21 20 19 18 17 36 63
50 49 48 47 46 45 44 43 42 41 40 39 38 37 64
The eight nearest neighbors of 4 are: 1, 3, 14, 33, 15, 5, 6, 7. Their sum is a(4)=84.
		

Crossrefs

Cf. A214226 - same sum in a triangular "horizontal-last" spiral.

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,chkX2,chkY2):
      global posX, posY, n
      while 1:
        posX+=stepX
        posY+=stepY
        grid[posY*SIZE+posX]=n
        saveX[n]=posX
        saveY[n]=posY
        n+=1
        if posX==0 or grid[(posY+chkY)*SIZE+posX+chkX]+grid[(posY+chkY2)*SIZE+posX+chkX2]==0:
            return
    while 1:
        walk(-1, 0,  1, -1, 0, -1)   # left
        if posX==0:
            break
        walk( 1,-1,  1, 1,  1, 1)    # right+up
        walk( 1, 1, -1,  0, -1, 0)   # right+down
    for n in range(1,122):
        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=' ')

A214227 Sum of the four nearest neighbors of n in a triangular spiral with positive integers.

Original entry on oeis.org

24, 32, 20, 28, 56, 44, 64, 48, 60, 88, 60, 56, 60, 64, 68, 84, 128, 100, 92, 96, 136, 104, 108, 112, 132, 176, 132, 120, 124, 128, 132, 136, 140, 144, 148, 172, 232, 188, 172, 176, 180, 184, 240, 192, 196, 200, 204, 208, 236, 296, 236, 216, 220, 224, 228, 232, 236
Offset: 1

Views

Author

Alex Ratushnyak, Jul 07 2012

Keywords

Comments

Nearby numbers on diagonals are not counted as neighbors for this sequence.
The central 1 is at ?

Examples

			Triangular spiral begins:
.
                       43
                       / \
                      /   \
                    42 21 44
                    /  / \  \
                   /  /   \  \
                 41 20  7 22 45
                 /  /  / \  \  \
                /  /  /   \  \  \
              40 19  6  1  8 23 46
              /  /  /    \  \  \  \
             /  /  /      \  \  \  \
           39 18  5--4--3--2  9 24 47
           /  /                \  \  \
          /  /                  \  \  \
        38 17-16-15-14-13-12-11-10 25 48
        /                            \  \
       /                              \  \
     37-36-35-34-33-32-31-30-29-28-27-26 49
                                           \
                                            \
  64-63-62-61-60-59-58-57-56-55-54-53-52-51-50
.
The four nearest neighbors of 3 are 1, 4, 2, 13; their sum is a(3)=20.
		

Crossrefs

Cf. A214226 (sum of the 8 nearest neighbors).
Showing 1-6 of 6 results.