%I #8 Jul 26 2012 12:59:27
%S 62,64,69,125,94,111,170,118,105,116,169,132,131,151,192,284,217,201,
%T 206,220,258,353,265,234,227,235,243,269,349,285,275,283,291,299,328,
%U 387,515,412,378,374,382,390,398,421,477,608,484,435,419,427,435
%N Sum of the eight nearest neighbors of n in a right triangular type-2 spiral with positive integers.
%C Right triangular type-1 spiral (A214230): implements the sequence Up, Right-down, Left.
%C Right triangular type-2 spiral: Left, Up, Right-down.
%C Right triangular type-3 spiral (A214252): Right-down, Left, Up.
%e Right triangular type-2 spiral begins:
%e 67
%e 66 68
%e 65 37 69
%e 64 36 38 70
%e 63 35 16 39 71
%e 62 34 15 17 40 72
%e 61 33 14 4 18 41 73
%e 60 32 13 3 5 19 42 74
%e 59 31 12 2 1 6 20 43 75
%e 58 30 11 10 9 8 7 21 44 76
%e 57 29 28 27 26 25 24 23 22 45 77
%e 56 55 54 53 52 51 50 49 48 47 46 78
%e The eight nearest neighbors of 5 are 1, 2, 3, 4, 18, 41, 19, 6. Their sum is a(5)=94.
%o (Python)
%o SIZE=29 # must be odd
%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 1:
%o walk(-1, 0, 0, -1) # left
%o walk(0, -1, 1, 1) # up
%o if posY==0:
%o break
%o walk( 1, 1, -1, 0) # right-down
%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. A214252.
%K nonn,easy
%O 1,1
%A _Alex Ratushnyak_, Jul 08 2012