Skip to content

Commit

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


def cache(func: Callable) -> Callable:
# Write your code here
pass
results = {}
def inner(*args) -> None:
if func.__name__ in results and args in results[func.__name__]:
print("Getting from cache")
return results[func.__name__][args]

print("Calculating new result")
result = func(*args)
if func.__name__ not in results:
results[func.__name__] = {}

results[func.__name__][args] = result

return result

return inner

0 comments on commit 71c6b68

Please sign in to comment.