login
A275122
Pascal's hexagonal pyramid, read by slices, with each slice read by rows.
1
1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 4, 4, 2, 1, 4, 7, 4, 1, 2, 4, 4, 2, 1, 2, 1, 1, 3, 3, 1, 3, 9, 12, 9, 3, 3, 12, 24, 24, 12, 3, 1, 9, 24, 31, 24, 9, 1, 3, 12, 24, 24, 12, 3, 3, 9, 12, 9, 3, 1, 3, 3, 1
OFFSET
1,10
COMMENTS
Each layer is a hexagon of numbers.
Every cell has 7 neighbors: itself and the 6 around it.
The sum of the values of the neighbors of a cell in one layer is the value of that cell in the next.
Layer 0:
1
Layer 1:
1 1
1 1 1
1 1
Layer 2:
1 2 1
2 4 4 2
1 4 7 4 1
2 4 4 2
1 2 1
Layer 3:
1 3 3 1
.
3 9 12 9 3
.
3 12 24 24 12 3
.
1 9 24 31 24 9 1
.
3 12 24 24 12 3
.
3 9 12 9 3
.
1 3 3 1
etc.
LINKS
Wikipedia, Hexaflake
FORMULA
Odd terms in layer x, where x is 1 less than a power of 2, form a hexaflake (conjectured).
EXAMPLE
Layer 0 is a single 1, so a(1) = 1.
Layer 1 is a filled hexagon of seven 1's, so a(2) through a(8) = 1.
The numbers in the top row of Layer 2, "1 2 1", become terms a(9) through a(11).
PROG
(Python)
import numpy as np
# This is used for the terms[] array
numLayers = 22
# Number of layers that you want to generate
# Number of terms = numLayers^3
width = numLayers*2
# Width and height of the terms[] array
neighbors = [[0, 0], [0, 1], [1, 0], [1, 1], [1, 2], [2, 1], [2, 2]]
# Neighbors of terms that are added together
terms = np.zeros((numLayers, width, width))
# Initialize terms[] array with specified dimensions and fill it with zeros
terms[0][0][0] = 1
# Place a single 1 in layer 0
for l in range(1, numLayers):
for x in range(width):
for y in range(width):
for n in neighbors:
terms[l][x][y] += terms[l-1][x-n[0]][y-n[1]]
# Calculate terms
seq = terms.flatten().tolist()
# List containing all terms in array
while 0 in seq:
seq.remove(0)
# Remove zeros from array
for s in range(len(seq)):
seq[s] = int(seq[s])
# Turn all terms from floats to integers
final = ""
for s in range(len(seq)):
final += str(s+1)+" "+str(seq[s])+"\n"
# Put the terms into a single string in b-file format
bfile = open("b275122.txt", "w")
bfile.write(final)
bfile.close()
# Write this string to the b-file
CROSSREFS
Sequence in context: A230535 A349741 A257651 * A264569 A265601 A349816
KEYWORD
nonn,look
AUTHOR
Aresh Pourkavoos, Jul 18 2016
STATUS
approved