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

 

Logo


Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A217014 Permutation of natural numbers arising from applying the walk of a square spiral (e.g. A214526) to the data of triangular horizontal-last spiral (defined in A214226). 2
1, 7, 22, 8, 2, 3, 4, 6, 20, 42, 21, 44, 75, 45, 23, 9, 11, 12, 13, 14, 15, 5, 19, 41, 71, 109, 72, 43, 74, 113, 160, 114, 76, 46, 24, 10, 28, 29, 30, 31, 32, 33, 34, 16, 18, 40, 70, 108, 154, 208, 155, 110, 73, 112, 159, 214 (list; graph; refs; listen; history; text; internal format)
OFFSET

1,2

LINKS

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

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,  1, -1,  0)    # down-right

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

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

    if posX<2:

        break

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

Cf. A090861, A214526, A214226, A217010.

Sequence in context: A082826 A130740 A101119 * A200886 A070412 A286572

Adjacent sequences:  A217011 A217012 A217013 * A217015 A217016 A217017

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 | Recent
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified May 25 04:50 EDT 2019. Contains 323539 sequences. (Running on oeis4.)