mirror of
https://github.com/jlengrand/project_euler.git
synced 2026-03-10 08:41:20 +00:00
Prepares some others. More than 35 problem solved ! Signed-off-by: Julien Lengrand-Lambert <julien@lengrand.fr>
19 lines
437 B
Python
19 lines
437 B
Python
#!/usr/bin/env python
|
|
'''
|
|
Created on 17 feb. 2012
|
|
|
|
@author: Julien Lengrand-Lambert
|
|
@contact: julien@lengrand.fr
|
|
'''
|
|
|
|
def memoize(function):
|
|
"""Defines a memoization scheme"""
|
|
cache = {}
|
|
def decorated_function(*args):
|
|
if args in cache:
|
|
return cache[args]
|
|
else:
|
|
val = function(*args)
|
|
cache[args] = val
|
|
return val
|
|
return decorated_function |