Skip to content

Commit

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


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

def inner(*args, **kwargs) -> func:
key = (args, tuple(sorted(kwargs.items())))
if key not in results:
print("Calculating new result")
result = func(*args, **kwargs)
results[key] = result
return result
else:
print("Getting from cache")
return results[key]
return inner

0 comments on commit 27fc61f

Please sign in to comment.