login
This site is supported by donations 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
62, 88, 63, 89, 76, 102, 170, 127, 126, 152, 223, 159, 140, 139, 159, 221, 175, 171, 179, 202, 249, 353, 274, 252, 254, 262, 279, 323, 430, 330, 293, 283, 291, 299, 307, 336, 425, 352, 339, 347, 355, 363, 371, 403, 468, 608, 493, 453, 446, 454, 462, 470, 478, 504 (list; graph; refs; listen; history; text; internal format)
OFFSET

1,1

COMMENTS

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

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

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

LINKS

Table of n, a(n) for n=1..54.

EXAMPLE

Right triangular type-3 spiral begins:

78

77  46

76  45  47

75  44  22  48

74  43  21  23  49

73  42  20   7  24  50

72  41  19   6   8  25  51

71  40  18   5   1   9  26  52

70  39  17   4   3   2  10  27  53

69  38  16  15  14  13  12  11  28  54

68  37  36  35  34  33  32  31  30  29  55

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

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

PROG

(Python)

SIZE=28  # must be even

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):

  global posX, posY, n

  while 1:

    posX+=stepX

    posY+=stepY

    grid[posY*SIZE+posX]=n

    saveX[n]=posX

    saveY[n]=posY

    n+=1

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

        return

while posY!=0:

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

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

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

for n in range(1, 92):

    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,

CROSSREFS

Cf. A214230.

Cf. A214251.

Sequence in context: A043994 A039479 A118156 * A282241 A114966 A104078

Adjacent sequences:  A214249 A214250 A214251 * A214253 A214254 A214255

KEYWORD

nonn,easy

AUTHOR

Alex Ratushnyak, Jul 08 2012

STATUS

approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recent | More pages
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy .

Last modified May 24 21:25 EDT 2017. Contains 287008 sequences.