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

A217011 Permutation of natural numbers arising from applying the walk of a square spiral (e.g. A214526) to the data of right triangular type-2 spiral (defined in A214251).

Original entry on oeis.org

1, 5, 19, 6, 8, 9, 10, 2, 3, 4, 18, 41, 73, 42, 20, 7, 24, 25, 26, 27, 28, 11, 12, 13, 14, 15, 17, 40, 72, 113, 163, 114, 74, 43, 21, 23, 49, 50, 51, 52, 53, 54, 55, 29, 30, 31, 32, 33, 34, 35, 16, 39, 71, 112, 162, 221
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, 0,  0, -1)    # left
        walk(0, -1,  1,  1)    # up
        if posY==0:
            break
        walk( 1, 1, -1,  0)    # right-down
    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

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

Original entry on oeis.org

1, 8, 9, 10, 2, 4, 16, 5, 6, 7, 22, 23, 24, 25, 26, 51, 27, 11, 3, 15, 35, 63, 36, 17, 18, 19, 20, 21, 44, 45, 46, 47, 48, 49, 50, 83, 124, 84, 52, 28, 12, 14, 34, 62, 98, 142, 99, 64, 37, 38, 39, 40, 41, 42, 43, 74, 75, 76, 77, 78, 79, 80, 81, 82, 123, 172, 229
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, 0,  0, -1)    # left
        walk2(0, -1,  1,  1)    # up
        if posY==0:
            break
        walk2( 1, 1, -1,  0)    # right-down

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

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=' ')
Showing 1-5 of 5 results.