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.
%I A217015 #7 Mar 12 2025 18:35:47 %S A217015 1,5,6,2,8,3,10,4,12,24,13,14,27,15,7,17,31,18,9,20,35,21,11,23,39,59, %T A217015 40,25,26,43,64,44,28,16,30,48,70,49,32,19,34,53,76,54,36,22,38,58,82, %U A217015 110,83,60,41,42,63,88,117,89,65,45,29,47,69,95,125,96,71,50 %N A217015 Permutation of natural numbers arising from applying the walk of a square spiral (e.g. A214526) to the data of rotated-square spiral (defined in A215468). %o A217015 (Python) %o A217015 SIZE = 33 # must be 4k+1 %o A217015 grid = [0] * (SIZE*SIZE) %o A217015 posX = posY = SIZE//2 %o A217015 grid[posY*SIZE+posX]=1 %o A217015 posX += 1 %o A217015 grid[posY*SIZE+posX]=2 %o A217015 n = 3 %o A217015 def walk(stepX, stepY, chkX, chkY): %o A217015 global posX, posY, n %o A217015 while 1: %o A217015 posX+=stepX %o A217015 posY+=stepY %o A217015 grid[posY*SIZE+posX]=n %o A217015 n+=1 %o A217015 if grid[(posY+chkY)*SIZE+posX+chkX]==0: %o A217015 return %o A217015 while posX!=SIZE-1: %o A217015 walk(-1, 1, -1, -1) # down-left %o A217015 walk(-1, -1, 1, -1) # up-left %o A217015 walk( 1, -1, 1, 0) # up-right %o A217015 walk( 1, 0, 1, 1) # right %o A217015 walk( 1, 1, -1, 1) # down-right %o A217015 import sys %o A217015 grid2 = [0] * (SIZE*SIZE) %o A217015 posX = posY = SIZE//2 %o A217015 grid2[posY*SIZE+posX]=1 %o A217015 def walk2(stepX, stepY, chkX, chkY): %o A217015 global posX, posY %o A217015 while 1: %o A217015 a = grid[posY*SIZE+posX] %o A217015 if a==0: %o A217015 sys.exit(1) %o A217015 print(a, end=', ') %o A217015 posX+=stepX %o A217015 posY+=stepY %o A217015 grid2[posY*SIZE+posX]=1 %o A217015 if grid2[(posY+chkY)*SIZE+posX+chkX]==0: %o A217015 return %o A217015 while 1: %o A217015 walk2(0, -1, 1, 0) # up %o A217015 walk2(1, 0, 0, 1) # right %o A217015 walk2(0, 1, -1, 0) # down %o A217015 walk2(-1, 0, 0, -1) # left %Y A217015 Cf. A090861, A214526, A215468, A217010. %K A217015 nonn,easy %O A217015 1,2 %A A217015 _Alex Ratushnyak_, Sep 23 2012