Skip to content

Commit

Permalink
Solution
Browse files Browse the repository at this point in the history
  • Loading branch information
vshvanska committed Sep 28, 2023
1 parent 5891c38 commit 6c5d536
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions app/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
from typing import Callable
from typing import Callable, Any


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

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

return wrapper

0 comments on commit 6c5d536

Please sign in to comment.