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.

A217296 Permutation of natural numbers arising from applying the walk of rotated-square spiral (defined in A215468) to the data of square spiral (e.g. A214526).

This page as a plain text file.
%I A217296 #12 May 09 2021 09:51:50
%S A217296 1,4,6,8,2,3,15,5,19,7,23,9,11,12,14,34,16,18,40,20,22,46,24,10,28,29,
%T A217296 13,33,61,35,17,39,69,41,21,45,77,47,25,27,53,54,30,32,60,96,62,36,38,
%U A217296 68,106,70,42,44,76,116,78,48,26,52,86,87,55,31,59,95,139
%N A217296 Permutation of natural numbers arising from applying the walk of rotated-square spiral (defined in A215468) to the data of square spiral (e.g. A214526).
%H A217296 <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a>
%o A217296 (Python)
%o A217296 SIZE = 29    # must be 4k+1
%o A217296 grid = [0] * (SIZE*SIZE)
%o A217296 posX = posY = SIZE//2
%o A217296 grid[posY*SIZE+posX]=1
%o A217296 n = 2
%o A217296 def walk(stepX, stepY, chkX, chkY):
%o A217296   global posX, posY, n
%o A217296   while 1:
%o A217296     posX+=stepX
%o A217296     posY+=stepY
%o A217296     grid[posY*SIZE+posX]=n
%o A217296     n+=1
%o A217296     if grid[(posY+chkY)*SIZE+posX+chkX]==0:
%o A217296         return
%o A217296 while posX:
%o A217296     walk(0, -1, 1, 0)    # up
%o A217296     walk(1, 0, 0, 1)     # right
%o A217296     walk(0, 1, -1, 0)    # down
%o A217296     walk(-1, 0, 0, -1)   # left
%o A217296 grid2 = [0] * (SIZE*SIZE)
%o A217296 posY = SIZE//2
%o A217296 posX = posY+1
%o A217296 grid2[posY*SIZE+posX-1] = grid2[posY*SIZE+posX] = 1
%o A217296 print(1, end=',')
%o A217296 def walk2(stepX, stepY, chkX, chkY):
%o A217296   global posX, posY
%o A217296   while 1:
%o A217296     a = grid[posY*SIZE+posX]
%o A217296     if a==0:
%o A217296         raise ValueError
%o A217296     print(a, end=',')
%o A217296     posX+=stepX
%o A217296     posY+=stepY
%o A217296     grid2[posY*SIZE+posX]=1
%o A217296     if grid2[(posY+chkY)*SIZE+posX+chkX]==0:
%o A217296         return
%o A217296 while posX!=SIZE-1:
%o A217296     walk2(-1,  1, -1, -1)    # down-left
%o A217296     walk2(-1, -1,  1, -1)    # up-left
%o A217296     walk2( 1, -1,  1,  0)    # up-right
%o A217296     walk2( 1,  0,  1,  1)    # right
%o A217296     walk2( 1,  1, -1,  1)    # down-right
%Y A217296 Cf. A215468, A214526, A217015.
%K A217296 nonn
%O A217296 1,2
%A A217296 _Alex Ratushnyak_, Sep 30 2012