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.

A217010 Permutation of natural numbers arising from applying the walk of a square spiral (e.g., A214526) to the data of right triangular type-1 spiral (defined in A214230).

This page as a plain text file.
%I A217010 #13 Mar 12 2025 20:07:59
%S A217010 1,2,13,3,5,6,7,8,9,10,12,32,61,33,14,4,18,19,20,21,22,23,24,25,26,27,
%T A217010 11,31,60,98,145,99,62,34,15,17,40,41,42,43,44,45,46,47,48,49,50,51,
%U A217010 52,53,28,30,59,97,144,200,265,201,146,100,63,35,16,39,71
%N A217010 Permutation of natural numbers arising from applying the walk of a square spiral (e.g., A214526) to the data of right triangular type-1 spiral (defined in A214230).
%e A217010 Triangular spiral (A214230) begins:
%e A217010 .
%e A217010   56
%e A217010    | \
%e A217010   55  57
%e A217010    |     \
%e A217010   54  29  58
%e A217010    |   | \   \
%e A217010   53  28  30  59
%e A217010    |   |     \   \
%e A217010   52  27  11  31  60
%e A217010    |   |   | \   \   \
%e A217010   51  26  10  12  32  61
%e A217010    |   |   |     \   \   \
%e A217010   50  25   9   2  13  33  62
%e A217010    |   |   |   | \   \   \   \
%e A217010   49  24   8   1   3  14  34  63
%e A217010    |   |   |         \   \   \   \
%e A217010   48  23   7---6---5---4  15  35  64
%e A217010    |   |                     \   \   \
%e A217010   47  22--21--20--19--18--17--16  36  65
%e A217010    |                                 \   \
%e A217010   46--45--44--43--42--41--40--39--38--37  66
%e A217010                                              \
%e A217010   78--77--76--75--74--73--72--71--70--69--68--67
%e A217010 .
%e A217010 Square spiral (defining order in which elements are fetched) begins:
%e A217010 .
%e A217010   49  26--27--28--29--30--31
%e A217010    |   |                   |
%e A217010   48  25  10--11--12--13  32
%e A217010    |   |   |           |   |
%e A217010   47  24   9   2---3  14  33
%e A217010    |   |   |   |   |   |   |
%e A217010   46  23   8   1   4  15  34
%e A217010    |   |   |       |   |   |
%e A217010   45  22   7---6---5  16  35
%e A217010    |   |               |   |
%e A217010   44  21--20--19--18--17  36
%e A217010    |                       |
%e A217010   43--42--41--40--39--38--37
%o A217010 (Python)
%o A217010 SIZE = 33       # must be 4k+1
%o A217010 grid = [0] * (SIZE*SIZE)
%o A217010 posX = posY = SIZE//2
%o A217010 grid[posY*SIZE+posX]=1
%o A217010 n = 2
%o A217010 def walk(stepX, stepY, chkX, chkY):
%o A217010   global posX, posY, n
%o A217010   while 1:
%o A217010     posX+=stepX
%o A217010     posY+=stepY
%o A217010     grid[posY*SIZE+posX]=n
%o A217010     n+=1
%o A217010     if grid[(posY+chkY)*SIZE+posX+chkX]==0:
%o A217010         return
%o A217010 while 1:
%o A217010     walk(0, -1,  1,  1)    # up
%o A217010     walk( 1, 1, -1,  0)    # right-down
%o A217010     if posX==SIZE-1:
%o A217010         break
%o A217010     walk(-1, 0,  0, -1)    # left
%o A217010 import sys
%o A217010 grid2 = [0] * (SIZE*SIZE)
%o A217010 posX = posY = SIZE//2
%o A217010 grid2[posY*SIZE+posX]=1
%o A217010 def walk2(stepX, stepY, chkX, chkY):
%o A217010   global posX, posY
%o A217010   while 1:
%o A217010     a = grid[posY*SIZE+posX]
%o A217010     if a==0:
%o A217010         sys.exit(1)
%o A217010     print(a, end=', ')
%o A217010     posX+=stepX
%o A217010     posY+=stepY
%o A217010     grid2[posY*SIZE+posX]=1
%o A217010     if grid2[(posY+chkY)*SIZE+posX+chkX]==0:
%o A217010         return
%o A217010 while posX:
%o A217010     walk2(0, -1, 1, 0)    # up
%o A217010     walk2(1, 0, 0, 1)     # right
%o A217010     walk2(0, 1, -1, 0)    # down
%o A217010     walk2(-1, 0, 0, -1)   # left
%Y A217010 Cf. A090861, A214526, A214230.
%K A217010 nonn,easy
%O A217010 1,2
%A A217010 _Alex Ratushnyak_, Sep 23 2012