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!)
A217015 Permutation of natural numbers arising from applying the walk of a square spiral (e.g. A214526) to the data of rotated-square spiral (defined in A215468). 4
1, 5, 6, 2, 8, 3, 10, 4, 12, 24, 13, 14, 27, 15, 7, 17, 31, 18, 9, 20, 35, 21, 11, 23, 39, 59, 40, 25, 26, 43, 64, 44, 28, 16, 30, 48, 70, 49, 32, 19, 34, 53, 76, 54, 36, 22, 38, 58, 82, 110, 83, 60, 41, 42, 63, 88, 117, 89, 65, 45, 29, 47, 69, 95, 125, 96, 71, 50 (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
posX += 1
grid[posY*SIZE+posX]=2
n = 3
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 posX!=SIZE-1:
walk(-1, 1, -1, -1) # down-left
walk(-1, -1, 1, -1) # up-left
walk( 1, -1, 1, 0) # up-right
walk( 1, 0, 1, 1) # right
walk( 1, 1, -1, 1) # down-right
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: A154801 A253094 A346046 * A107825 A201332 A049253
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 April 27 11:10 EDT 2024. Contains 372019 sequences. (Running on oeis4.)