Skip to content

Commit

Permalink
solution
Browse files Browse the repository at this point in the history
  • Loading branch information
MaksymStarodubtsev committed Nov 5, 2024
1 parent 5891c38 commit e3aa4e2
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_data: dict = {}

def wrapper(*args, **kwargs) -> int:
key = ",".join(str(arg) for arg in args)

if key in cache_data:
print("Getting from cache")
else:
cache_data[key] = func(*args, **kwargs)
print("Calculating new result")

return cache_data[key]

return wrapper

0 comments on commit e3aa4e2

Please sign in to comment.