Skip to content

Commit

Permalink
Solution
Browse files Browse the repository at this point in the history
  • Loading branch information
ADRIREG committed Nov 22, 2024
1 parent 5891c38 commit b9a126f
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions app/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
from typing import Callable
from functools import wraps


def cache(func: Callable) -> Callable:
# Write your code here
pass

results = dict({})

@wraps(func)
def wrapper(*args) -> callable:
if args in results:
print("Getting from cache")
return results[args]
else:
print("Calculating new result")
result = func(*args)
results[args] = result
return result
return wrapper

0 comments on commit b9a126f

Please sign in to comment.