Last active
March 1, 2016 18:57
-
-
Save BBischof/718a9dfea4f5678607c3 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 memoize(f): | |
cache = {} | |
def decorated_function(*args): | |
if args in cache: | |
return cache[args] | |
else: | |
cache[args] = f(*args) | |
return cache[args] | |
return decorated_function | |
@memoize | |
def furtburl(integer): | |
n = int(integer) | |
if (n<0): | |
return 0 | |
elif (n==0): | |
return 1 | |
else: | |
return furtburl(n-8)+furtburl(n-7)+furtburl(n-6)+furtburl(n-3)+furtburl(n-2) | |
furtburl(40) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment