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.

A217013 Permutation of natural numbers arising from applying the walk of a square spiral (e.g. A214526) to the data of triangular horizontal-first spiral (defined in A214250).

This page as a plain text file.
%I A217013 #8 Mar 12 2025 21:11:01
%S A217013 1,3,14,4,6,7,8,2,12,30,13,32,59,33,15,5,19,20,21,22,23,9,11,29,55,89,
%T A217013 56,31,58,93,136,94,60,34,16,18,40,41,42,43,44,45,46,24,10,28,54,88,
%U A217013 130,180,131,90,57,92,135,186,245,187,137,95,61,35,17,39,69
%N A217013 Permutation of natural numbers arising from applying the walk of a square spiral (e.g. A214526) to the data of triangular horizontal-first spiral (defined in A214250).
%o A217013 (Python)
%o A217013 SIZE = 33       # must be 4k+1
%o A217013 grid = [0] * (SIZE*SIZE)
%o A217013 posX = posY = SIZE//2
%o A217013 grid[posY*SIZE+posX]=1
%o A217013 n = 2
%o A217013 def walk(stepX, stepY, chkX, chkY):
%o A217013   global posX, posY, n
%o A217013   while 1:
%o A217013     posX+=stepX
%o A217013     posY+=stepY
%o A217013     grid[posY*SIZE+posX]=n
%o A217013     n+=1
%o A217013     if grid[(posY+chkY)*SIZE+posX+chkX]==0:
%o A217013         return
%o A217013 while posX<SIZE-2:
%o A217013     walk(-1, 0,  1, -1)    # left
%o A217013     walk(1, -1,  1,  1)    # up-right
%o A217013     walk(1,  1, -1,  0)    # down-right
%o A217013     walk(-1, 0,  1, -1)    # left
%o A217013 import sys
%o A217013 grid2 = [0] * (SIZE*SIZE)
%o A217013 posX = posY = SIZE//2
%o A217013 grid2[posY*SIZE+posX]=1
%o A217013 def walk2(stepX, stepY, chkX, chkY):
%o A217013   global posX, posY
%o A217013   while 1:
%o A217013     a = grid[posY*SIZE+posX]
%o A217013     if a==0:
%o A217013         sys.exit(1)
%o A217013     print(a, end=', ')
%o A217013     posX+=stepX
%o A217013     posY+=stepY
%o A217013     grid2[posY*SIZE+posX]=1
%o A217013     if grid2[(posY+chkY)*SIZE+posX+chkX]==0:
%o A217013         return
%o A217013 while 1:
%o A217013     walk2(0, -1, 1, 0)    # up
%o A217013     walk2(1, 0, 0, 1)     # right
%o A217013     walk2(0, 1, -1, 0)    # down
%o A217013     walk2(-1, 0, 0, -1)   # left
%Y A217013 Cf. A090861, A214526, A214250, A217010.
%K A217013 nonn,easy
%O A217013 1,2
%A A217013 _Alex Ratushnyak_, Sep 23 2012