login
This site is supported by donations to The OEIS Foundation.

 

Logo


Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A217296 Permutation of natural numbers arising from applying the walk of rotated-square spiral (defined in A215468) to the data of square spiral (e.g. A214526). 2
1, 4, 6, 8, 2, 3, 15, 5, 19, 7, 23, 9, 11, 12, 14, 34, 16, 18, 40, 20, 22, 46, 24, 10, 28, 29, 13, 33, 61, 35, 17, 39, 69, 41, 21, 45, 77, 47, 25, 27, 53, 54, 30, 32, 60, 96, 62, 36, 38, 68, 106, 70, 42, 44, 76, 116, 78, 48, 26, 52, 86, 87, 55, 31, 59, 95, 139 (list; graph; refs; listen; history; text; internal format)
OFFSET

1,2

LINKS

Table of n, a(n) for n=1..67.

PROG

(Python)

SIZE = 29    # 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 posX:

    walk(0, -1, 1, 0)    # up

    walk(1, 0, 0, 1)     # right

    walk(0, 1, -1, 0)    # down

    walk(-1, 0, 0, -1)   # left

import sys

grid2 = [0] * (SIZE*SIZE)

posY = SIZE//2

posX = posY+1

grid2[posY*SIZE+posX-1] = grid2[posY*SIZE+posX] = 1

print 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 posX!=SIZE-1:

    walk2(-1,  1, -1, -1)    # down-left

    walk2(-1, -1,  1, -1)    # up-left

    walk2( 1, -1,  1,  0)    # up-right

    walk2( 1,  0,  1,  1)    # right

    walk2( 1,  1, -1,  1)    # down-right

CROSSREFS

Cf. A215468, A214526, A217015.

Sequence in context: A181097 A206798 A200366 * A179371 A097455 A201520

Adjacent sequences:  A217293 A217294 A217295 * A217297 A217298 A217299

KEYWORD

nonn

AUTHOR

Alex Ratushnyak, Sep 30 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 | Recent
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified June 17 22:17 EDT 2019. Contains 324200 sequences. (Running on oeis4.)