Skip to content

Commit

Permalink
Solution
Browse files Browse the repository at this point in the history
  • Loading branch information
Bondaliname committed Dec 11, 2024
1 parent 5891c38 commit 1ec336f
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,15 @@


def cache(func: Callable) -> Callable:
# Write your code here
pass
cache_func = {}
def wrapper(*args, **kwargs) -> str:
key = (args, frozenset(kwargs.items()))
if key in cache_func:
print("Getting from cache")
return cache_func[key]
else:
print("Calculating new result")
result = func(*args, **kwargs)
cache_func[key] = result
return result
return wrapper

0 comments on commit 1ec336f

Please sign in to comment.