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

 

Logo


Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A217291 Permutation of natural numbers arising from applying the walk of right triangular type-1 spiral (defined in A214230) to the data of square spiral (e.g. A214526). 0
1, 2, 4, 16, 5, 6, 7, 8, 9, 10, 27, 11, 3, 15, 35, 63, 36, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 51, 84, 52, 28, 12, 14, 34, 62, 98, 142, 99, 64, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 83, 124, 173, 125, 85, 53, 29, 13, 33, 61, 97, 141, 193, 253 (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)

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,  1)    # up

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

    if posX==SIZE-1:

        break

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

CROSSREFS

Cf. A214230, A214526, A217010.

Sequence in context: A125594 A097542 A277850 * A094670 A110005 A019540

Adjacent sequences:  A217288 A217289 A217290 * A217292 A217293 A217294

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 February 15 20:49 EST 2019. Contains 320138 sequences. (Running on oeis4.)