The OEIS mourns the passing of Jim Simons and is grateful to the Simons Foundation for its support of research in many branches of science, including the OEIS.
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!)
A217295 Permutation of natural numbers arising from applying the walk of triangular horizontal-last spiral (defined in A214226) to the data of square spiral (e.g. A214526). 0

%I #4 Oct 01 2012 01:50:46

%S 1,5,6,7,22,8,2,4,16,36,17,18,19,20,21,44,75,45,23,9,11,3,15,35,63,99,

%T 64,37,38,39,40,41,42,43,74,113,160,114,76,46,24,10,28,12,14,34,62,98,

%U 142,194,143,100,65,66,67,68,69,70,71,72,73,112,159,214,277

%N Permutation of natural numbers arising from applying the walk of triangular horizontal-last spiral (defined in A214226) to the data of square spiral (e.g. A214526).

%o (Python)

%o SIZE = 29 # must be 4k+1

%o grid = [0] * (SIZE*SIZE)

%o posX = posY = SIZE//2

%o grid[posY*SIZE+posX]=1

%o n = 2

%o def walk(stepX, stepY, chkX, chkY):

%o global posX, posY, n

%o while 1:

%o posX+=stepX

%o posY+=stepY

%o grid[posY*SIZE+posX]=n

%o n+=1

%o if grid[(posY+chkY)*SIZE+posX+chkX]==0:

%o return

%o while posX:

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

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

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

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

%o import sys

%o grid2 = [0] * (SIZE*SIZE)

%o posX = posY = SIZE//2

%o grid2[posY*SIZE+posX]=1

%o def walk2(stepX, stepY, chkX, chkY):

%o global posX, posY

%o while 1:

%o a = grid[posY*SIZE+posX]

%o if a==0:

%o sys.exit(1)

%o print a,

%o posX+=stepX

%o posY+=stepY

%o grid2[posY*SIZE+posX]=1

%o if grid2[(posY+chkY)*SIZE+posX+chkX]==0:

%o return

%o while 1:

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

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

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

%o if posX<2:

%o break

%o walk2(1, -1, 1, 1) # up-right

%Y Cf. A214226, A214526, A217014.

%K nonn

%O 1,2

%A _Alex Ratushnyak_, Sep 30 2012

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 May 23 11:57 EDT 2024. Contains 372763 sequences. (Running on oeis4.)