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!)
A214252 Sum of the eight nearest neighbors of n in a right triangular type-3 spiral with positive integers. 5

%I #8 Jul 26 2012 12:59:46

%S 62,88,63,89,76,102,170,127,126,152,223,159,140,139,159,221,175,171,

%T 179,202,249,353,274,252,254,262,279,323,430,330,293,283,291,299,307,

%U 336,425,352,339,347,355,363,371,403,468,608,493,453,446,454,462,470,478,504

%N Sum of the eight nearest neighbors of n in a right triangular type-3 spiral with positive integers.

%C Right triangular type-1 spiral (A214230): implements the sequence Up, Right-down, Left.

%C Right triangular type-2 spiral (A214251): Left, Up, Right-down.

%C Right triangular type-3 spiral: Right-down, Left, Up.

%e Right triangular type-3 spiral begins:

%e 78

%e 77 46

%e 76 45 47

%e 75 44 22 48

%e 74 43 21 23 49

%e 73 42 20 7 24 50

%e 72 41 19 6 8 25 51

%e 71 40 18 5 1 9 26 52

%e 70 39 17 4 3 2 10 27 53

%e 69 38 16 15 14 13 12 11 28 54

%e 68 37 36 35 34 33 32 31 30 29 55

%e 67 66 65 64 63 62 61 60 59 58 57 56

%e The eight nearest neighbors of 5 are 1, 3, 4, 17, 18, 19, 6, 8. Their sum is a(5)=76.

%o (Python)

%o SIZE=28 # must be even

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

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

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

%o saveX[1] = saveY[1] = 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 saveX[n]=posX

%o saveY[n]=posY

%o n+=1

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

%o return

%o while posY!=0:

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

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

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

%o for n in range(1, 92):

%o posX = saveX[n]

%o posY = saveY[n]

%o k = grid[(posY-1)*SIZE+posX] + grid[(posY+1)*SIZE+posX]

%o k+= grid[(posY-1)*SIZE+posX-1] + grid[(posY-1)*SIZE+posX+1]

%o k+= grid[(posY+1)*SIZE+posX-1] + grid[(posY+1)*SIZE+posX+1]

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

%o print k,

%Y Cf. A214230.

%Y Cf. A214251.

%K nonn,easy

%O 1,1

%A _Alex Ratushnyak_, Jul 08 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 April 19 18:05 EDT 2024. Contains 371798 sequences. (Running on oeis4.)