Skip to content

Instantly share code, notes, and snippets.

@BBischof
Last active March 1, 2016 18:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BBischof/718a9dfea4f5678607c3 to your computer and use it in GitHub Desktop.
Save BBischof/718a9dfea4f5678607c3 to your computer and use it in GitHub Desktop.
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