Created
October 26, 2018 07:25
-
-
Save fulmicoton/7ec993229f1d89cf2e0a1b607cc27202 to your computer and use it in GitHub Desktop.
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 fibo(n = 10): | |
els = [] | |
prev = 1 | |
next = 1 | |
for i in range(n): | |
(prev, next) = (next, prev+next) | |
els.append(prev) | |
return els | |
def stutter(g, a, b): | |
memory = [] | |
for i in range(b + 1): | |
try: | |
memory.append(g.next()) | |
except: | |
pass | |
print "MEMORY", memory | |
cursor = 0 | |
b = len(memory) - 1 | |
len_memory = len(memory) | |
while b>=a: | |
for l in range(a, b + 1): | |
# if len < len_memory: | |
print l | |
yield memory[cursor], memory[(cursor + l)%len(memory)] | |
try: | |
memory[cursor] = g.next() | |
except: | |
b -= 1 | |
cursor = (cursor + 1) % len(memory) | |
FIBO = fibo() | |
print FIBO | |
for el in stutter(iter(FIBO), 1, 2): | |
print el |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment