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

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

A220102 Permutation of natural numbers arising from applying the walk of square spiral (e.g. A214526) to the data of double square spiral (defined in A220098).

Original entry on oeis.org

1, 2, 4, 6, 8, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 50, 52, 54, 56
Offset: 1

Views

Author

Alex Ratushnyak, Dec 04 2012

Keywords

Crossrefs

Programs

  • C
    #include 
    #define SIZE 20
    int grid[SIZE][SIZE];
    int direction[] = {0, -1,  1, 0, 0, 1, -1, 0};
    main() {
      int i, j, x1, y1, x2, y2, stepSize;
      int direction1pos=0, direction2pos=4, val;
      x1 = y1 = x2 = y2 = SIZE/2;
      for (val=grid[y1][x1]=1, stepSize=0; ; ++stepSize) {
        if (x1<1 || x1>=SIZE-1 || x2<1 || x2>=SIZE-1) break;
        if (y1<1 || y1>=SIZE-1 || y2<1 || y2>=SIZE-1) break;
        for (i=stepSize|1; i; ++val,--i) {
          x1 += direction[direction1pos  ];
          y1 += direction[direction1pos+1];
          x2 += direction[direction2pos  ];
          y2 += direction[direction2pos+1];
          grid[y1][x1] = val*2;
          grid[y2][x2] = val*2+1;
        }
        direction1pos = (direction1pos+2) & 7;
        direction2pos = (direction2pos+2) & 7;
      }
      direction1pos=0;
      x1 = y1 = SIZE/2;
      for (stepSize=2; ; ++stepSize) {
        for (i=stepSize/2; i; --i) {
          if (grid[y1][x1]==0) return;
          printf("%d, ",grid[y1][x1]);
          x1 += direction[direction1pos  ];
          y1 += direction[direction1pos+1];
        }
        direction1pos = (direction1pos+2) & 7;
      }
    }
Showing 1-2 of 2 results.