Skip to content

Commit

Permalink
'Solution_v1.00'
Browse files Browse the repository at this point in the history
  • Loading branch information
DmytroPieskov committed Nov 9, 2024
1 parent 5891c38 commit 3479ee4
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,17 @@


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

def wrapper(*args) -> int:

template = ",".join(str(arg) for arg in args)
if template in cache_dict:
print("Getting from cache")
else:
cache_dict[template] = func(*args)
print("Calculating new result")

return cache_dict[template]

return wrapper

0 comments on commit 3479ee4

Please sign in to comment.