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.

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).

This page as a plain text file.
%I A217295 #8 Mar 12 2025 20:06:55
%S A217295 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,
%T A217295 64,37,38,39,40,41,42,43,74,113,160,114,76,46,24,10,28,12,14,34,62,98,
%U A217295 142,194,143,100,65,66,67,68,69,70,71,72,73,112,159,214,277
%N 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).
%o A217295 (Python)
%o A217295 SIZE = 29    # must be 4k+1
%o A217295 grid = [0] * (SIZE*SIZE)
%o A217295 posX = posY = SIZE//2
%o A217295 grid[posY*SIZE+posX]=1
%o A217295 n = 2
%o A217295 def walk(stepX, stepY, chkX, chkY):
%o A217295   global posX, posY, n
%o A217295   while 1:
%o A217295     posX+=stepX
%o A217295     posY+=stepY
%o A217295     grid[posY*SIZE+posX]=n
%o A217295     n+=1
%o A217295     if grid[(posY+chkY)*SIZE+posX+chkX]==0:
%o A217295         return
%o A217295 while posX:
%o A217295     walk(0, -1, 1, 0)    # up
%o A217295     walk(1, 0, 0, 1)     # right
%o A217295     walk(0, 1, -1, 0)    # down
%o A217295     walk(-1, 0, 0, -1)   # left
%o A217295 import sys
%o A217295 grid2 = [0] * (SIZE*SIZE)
%o A217295 posX = posY = SIZE//2
%o A217295 grid2[posY*SIZE+posX]=1
%o A217295 def walk2(stepX, stepY, chkX, chkY):
%o A217295   global posX, posY
%o A217295   while 1:
%o A217295     a = grid[posY*SIZE+posX]
%o A217295     if a==0:
%o A217295         sys.exit(1)
%o A217295     print(a, end=', ')
%o A217295     posX+=stepX
%o A217295     posY+=stepY
%o A217295     grid2[posY*SIZE+posX]=1
%o A217295     if grid2[(posY+chkY)*SIZE+posX+chkX]==0:
%o A217295         return
%o A217295 while 1:
%o A217295     walk2(1,  1, -1,  0)    # down-right
%o A217295     walk2(-1, 0,  1, -1)    # left
%o A217295     walk2(-1, 0,  1, -1)    # left
%o A217295     if posX<2:
%o A217295         break
%o A217295     walk2(1, -1,  1,  1)    # up-right
%Y A217295 Cf. A214226, A214526, A217014.
%K A217295 nonn
%O A217295 1,2
%A A217295 _Alex Ratushnyak_, Sep 30 2012