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!)
A217010 Permutation of natural numbers arising from applying the walk of a square spiral (e.g., A214526) to the data of right triangular type-1 spiral (defined in A214230). 10

%I #9 Aug 12 2018 17:23:14

%S 1,2,13,3,5,6,7,8,9,10,12,32,61,33,14,4,18,19,20,21,22,23,24,25,26,27,

%T 11,31,60,98,145,99,62,34,15,17,40,41,42,43,44,45,46,47,48,49,50,51,

%U 52,53,28,30,59,97,144,200,265,201,146,100,63,35,16,39,71

%N Permutation of natural numbers arising from applying the walk of a square spiral (e.g., A214526) to the data of right triangular type-1 spiral (defined in A214230).

%e Triangular spiral (A214230) begins:

%e .

%e 56

%e | \

%e 55 57

%e | \

%e 54 29 58

%e | | \ \

%e 53 28 30 59

%e | | \ \

%e 52 27 11 31 60

%e | | | \ \ \

%e 51 26 10 12 32 61

%e | | | \ \ \

%e 50 25 9 2 13 33 62

%e | | | | \ \ \ \

%e 49 24 8 1 3 14 34 63

%e | | | \ \ \ \

%e 48 23 7---6---5---4 15 35 64

%e | | \ \ \

%e 47 22--21--20--19--18--17--16 36 65

%e | \ \

%e 46--45--44--43--42--41--40--39--38--37 66

%e \

%e 78--77--76--75--74--73--72--71--70--69--68--67

%e .

%e Square spiral (defining order in which elements are fetched) begins:

%e .

%e 49 26--27--28--29--30--31

%e | | |

%e 48 25 10--11--12--13 32

%e | | | | |

%e 47 24 9 2---3 14 33

%e | | | | | | |

%e 46 23 8 1 4 15 34

%e | | | | | |

%e 45 22 7---6---5 16 35

%e | | | |

%e 44 21--20--19--18--17 36

%e | |

%e 43--42--41--40--39--38--37

%o (Python)

%o SIZE = 33 # 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 1:

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

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

%o if posX==SIZE-1:

%o break

%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 posX:

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

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

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

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

%Y Cf. A090861, A214526, A214230.

%K nonn,easy

%O 1,2

%A _Alex Ratushnyak_, Sep 23 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 August 27 17:17 EDT 2024. Contains 375471 sequences. (Running on oeis4.)