Skip to content

Commit

Permalink
Solution
Browse files Browse the repository at this point in the history
  • Loading branch information
ostroverkhovaa committed Nov 18, 2024
1 parent 5891c38 commit 46ee03d
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
data = {}

def inner(*args) -> Any:
if args not in data:
print("Calculating new result")
result = func(*args)
data[args] = result
return result
if args in data:
print("Getting from cache")
return data[args]

return inner

0 comments on commit 46ee03d

Please sign in to comment.