login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A214226
Sum of the eight nearest neighbors of n in a triangular horizontal-last spiral with positive integers.
6
72, 80, 60, 76, 132, 100, 164, 112, 136, 200, 144, 128, 128, 136, 156, 196, 284, 220, 204, 208, 324, 224, 232, 248, 288, 384, 296, 264, 256, 264, 272, 280, 288, 296, 324, 380, 500, 404, 372, 368, 376, 384, 548, 400, 408, 416, 424, 448, 504, 632, 512, 464, 448
OFFSET
1,1
EXAMPLE
Triangular spiral begins:
__ __ __ __ __ __ __ 43
__ __ __ __ __ __ 42 21 44
__ __ __ __ __ 41 20 7 22 45
__ __ __ __ 40 19 6 1 8 23 46
__ __ __ 39 18 5 4 3 2 9 24 47
__ __ 38 17 16 15 14 13 12 11 10 25 48
__ 37 36 35 34 33 32 31 30 29 28 27 26 49
64 63 62 61 60 69 58 57 56 55 54 53 52 51 50
The eight nearest neighbors of 3 are 6, 1, 8, 4, 2, 14, 13, 12; their sum is a(3)=60.
PROG
(Python)
SIZE=27 # must be odd
grid = [0] * (SIZE*SIZE)
saveX = [0]* (SIZE*SIZE)
saveY = [0]* (SIZE*SIZE)
saveX[1] = saveY[1] = posX = posY = SIZE//2
grid[posY*SIZE+posX]=1
n = 2
def walk(stepX, stepY, chkX, chkY, chkX2, chkY2):
global posX, posY, n
while 1:
posX+=stepX
posY+=stepY
grid[posY*SIZE+posX]=n
saveX[n]=posX
saveY[n]=posY
n+=1
if posX==0 or grid[(posY+chkY)*SIZE+posX+chkX]+grid[(posY+chkY2)*SIZE+posX+chkX2]==0:
return
while 1:
walk( 1, 1, -1, 0, -1, 0) # right+down
walk(-1, 0, 1, -1, 0, -1) # left
if posX==0:
break
walk( 1, -1, 1, 1, 1, 1) # right+up
for n in range(1, 101):
posX = saveX[n]
posY = saveY[n]
k = grid[(posY-1)*SIZE+posX] + grid[(posY+1)*SIZE+posX]
k+= grid[(posY-1)*SIZE+posX-1] + grid[(posY-1)*SIZE+posX+1]
k+= grid[(posY+1)*SIZE+posX-1] + grid[(posY+1)*SIZE+posX+1]
k+= grid[posY*SIZE+posX-1] + grid[posY*SIZE+posX+1]
print(k, end=', ')
CROSSREFS
Cf. A002061 - numbers on the central vertical axis.
Cf. A054552 - numbers on the axis starting with 1 and 2.
Cf. A214227 - sum of the four nearest neighbors.
Cf. A214250 - same sum in a triangular "horizontal-first" spiral.
Sequence in context: A138691 A039670 A065147 * A043187 A039364 A043967
KEYWORD
nonn,easy
AUTHOR
Alex Ratushnyak, Jul 07 2012
STATUS
approved