Skip to content

Commit

Permalink
'Solution'
Browse files Browse the repository at this point in the history
  • Loading branch information
Bogdannna7 committed Dec 19, 2024
1 parent 5891c38 commit c4a01f7
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: Any) -> Any:
storage_keys = storage.keys()
if args not in storage_keys:
print("Calculating new result")
result = func(*args)
storage[args] = result
else:
print("Getting from cache")
result = storage[args]
return result
return wrapper

0 comments on commit c4a01f7

Please sign in to comment.