Created
March 27, 2011 06:46
-
-
Save cpdean/888994 to your computer and use it in GitHub Desktop.
line 28 is some bullshit
This file contains 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 fib(n): | |
if n in (0,1): | |
return n | |
else: | |
return fib(n-1) + fib(n-2) | |
def memoize(n): | |
cache = {} | |
def helper(x): | |
if x not in cache: | |
cache[x] = f(x) | |
return cache[x] | |
return helper | |
def regloop(x): | |
fib(0) | |
for bro in range(x): | |
print fib(bro) | |
def memoloop(x): | |
fib(0) | |
fib = memoize(fib) | |
for bro in range(x): | |
print fib(bro) | |
def main(): | |
#memoloop(30) | |
regloop(30) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment