Skip to content

Instantly share code, notes, and snippets.

@louisswarren louisswarren/pips.py
Created Nov 18, 2019

Embed
What would you like to do?
Graph sequence thing
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
You can’t perform that action at this time.