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 A217012 #8 Mar 12 2025 20:08:23 %S A217012 1,8,25,9,2,3,4,5,6,7,24,50,85,51,26,10,12,13,14,15,16,17,18,19,20,21, %T A217012 23,49,84,128,181,129,86,52,27,11,31,32,33,34,35,36,37,38,39,40,41,42, %U A217012 43,44,22,48,83,127,180,242 %N A217012 Permutation of natural numbers arising from applying the walk of a square spiral (e.g. A214526) to the data of right triangular type-3 spiral (defined in A214252). %o A217012 (Python) %o A217012 SIZE = 33 # must be 4k+1 %o A217012 grid = [0] * (SIZE*SIZE) %o A217012 posX = posY = SIZE//2 %o A217012 grid[posY*SIZE+posX]=1 %o A217012 n = 2 %o A217012 def walk(stepX, stepY, chkX, chkY): %o A217012 global posX, posY, n %o A217012 while 1: %o A217012 posX+=stepX %o A217012 posY+=stepY %o A217012 grid[posY*SIZE+posX]=n %o A217012 n+=1 %o A217012 if grid[(posY+chkY)*SIZE+posX+chkX]==0: %o A217012 return %o A217012 while posY!=0: %o A217012 walk( 1, 1, -1, 0) # right-down %o A217012 walk(-1, 0, 0, -1) # left %o A217012 walk(0, -1, 1, 1) # up %o A217012 import sys %o A217012 grid2 = [0] * (SIZE*SIZE) %o A217012 posX = posY = SIZE//2 %o A217012 grid2[posY*SIZE+posX]=1 %o A217012 def walk2(stepX, stepY, chkX, chkY): %o A217012 global posX, posY %o A217012 while 1: %o A217012 a = grid[posY*SIZE+posX] %o A217012 if a==0: %o A217012 sys.exit(1) %o A217012 print(a, end=', ') %o A217012 posX+=stepX %o A217012 posY+=stepY %o A217012 grid2[posY*SIZE+posX]=1 %o A217012 if grid2[(posY+chkY)*SIZE+posX+chkX]==0: %o A217012 return %o A217012 while 1: %o A217012 walk2(0, -1, 1, 0) # up %o A217012 walk2(1, 0, 0, 1) # right %o A217012 walk2(0, 1, -1, 0) # down %o A217012 walk2(-1, 0, 0, -1) # left %Y A217012 Cf. A090861, A214526, A214252, A217010. %K A217012 nonn,easy %O A217012 1,2 %A A217012 _Alex Ratushnyak_, Sep 23 2012