Created
November 18, 2019 11:10
-
-
Save louisswarren/9e3b9c0f796f1e4b6e0ab096837f1920 to your computer and use it in GitHub Desktop.
Graph sequence thing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def run(G, n): | |
for _ in range(n): | |
i = len(G[0]) - 1 | |
for j in range(len(G)): | |
s = 0 | |
if 0 <= j - 1: | |
s += G[j - 1][i] | |
if j + 1 < len(G): | |
s += G[j + 1][i] | |
G[j] += (s, ) | |
return ((x for x in seq if x != 0) for seq in G) | |
def output(k, n): | |
G = [(1,)] + [(0,)] * (k - 1) | |
for seq in run(G, n): | |
print(', '.join(map(str, seq))) | |
output(5, 20) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment