Skip to content

Commit

Permalink
solution
Browse files Browse the repository at this point in the history
  • Loading branch information
VovaGld committed Nov 12, 2024
1 parent 5891c38 commit 2dc274d
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions app/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
from typing import Callable
from typing import Callable, Any


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

def wrapper(*args: list) -> Any:
if args in storage:
print("Getting from cache")
return storage[args]
else:
result = func(*args)
storage[args] = result
print("Calculating new result")
return result

return wrapper

0 comments on commit 2dc274d

Please sign in to comment.