login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A217011 Permutation of natural numbers arising from applying the walk of a square spiral (e.g. A214526) to the data of right triangular type-2 spiral (defined in A214251). 2
1, 5, 19, 6, 8, 9, 10, 2, 3, 4, 18, 41, 73, 42, 20, 7, 24, 25, 26, 27, 28, 11, 12, 13, 14, 15, 17, 40, 72, 113, 163, 114, 74, 43, 21, 23, 49, 50, 51, 52, 53, 54, 55, 29, 30, 31, 32, 33, 34, 35, 16, 39, 71, 112, 162, 221 (list; graph; refs; listen; history; text; internal format)
OFFSET
1,2
LINKS
PROG
(Python)
SIZE = 33 # must be 4k+1
grid = [0] * (SIZE*SIZE)
posX = posY = SIZE//2
grid[posY*SIZE+posX]=1
n = 2
def walk(stepX, stepY, chkX, chkY):
global posX, posY, n
while 1:
posX+=stepX
posY+=stepY
grid[posY*SIZE+posX]=n
n+=1
if grid[(posY+chkY)*SIZE+posX+chkX]==0:
return
while 1:
walk(-1, 0, 0, -1) # left
walk(0, -1, 1, 1) # up
if posY==0:
break
walk( 1, 1, -1, 0) # right-down
import sys
grid2 = [0] * (SIZE*SIZE)
posX = posY = SIZE//2
grid2[posY*SIZE+posX]=1
def walk2(stepX, stepY, chkX, chkY):
global posX, posY
while 1:
a = grid[posY*SIZE+posX]
if a==0:
sys.exit(1)
print a,
posX+=stepX
posY+=stepY
grid2[posY*SIZE+posX]=1
if grid2[(posY+chkY)*SIZE+posX+chkX]==0:
return
while 1:
walk2(0, -1, 1, 0) # up
walk2(1, 0, 0, 1) # right
walk2(0, 1, -1, 0) # down
walk2(-1, 0, 0, -1) # left
CROSSREFS
Sequence in context: A274995 A370491 A089082 * A106229 A129734 A109325
KEYWORD
nonn,easy
AUTHOR
Alex Ratushnyak, Sep 23 2012
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified March 28 05:39 EDT 2024. Contains 371235 sequences. (Running on oeis4.)