Skip to content

Commit

Permalink
Solution
Browse files Browse the repository at this point in the history
  • Loading branch information
Vrungels committed Nov 8, 2024
1 parent 5891c38 commit d12d121
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 functools import wraps
from typing import Callable


def cache(func: Callable) -> Callable:
# Write your code here
pass
result = {}

@wraps(func)
def inner(*args) -> int:
if (func.__name__, args) not in result:
result[(func.__name__, args)] = \
result.get((func.__name__, args), func(*args))
print("Calculating new result")
else:
print("Getting from cache")

return result[(func.__name__, args)]

return inner

0 comments on commit d12d121

Please sign in to comment.