Skip to content

Commit

Permalink
Solution
Browse files Browse the repository at this point in the history
  • Loading branch information
ruslanyemets committed Nov 28, 2024
1 parent 5891c38 commit 0ec1d4a
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions app/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
from typing import Callable

from functools import wraps


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

@wraps(func)
def compare_cash(*args) -> dict:
func_name = func.__name__

if (func_name, args) not in cash_dict:
print("Calculating new result")
result = func(*args)
cash_dict[(func_name, args)] = result
return result
else:
print("Getting from cache")
return cash_dict[(func_name, args)]

return compare_cash

0 comments on commit 0ec1d4a

Please sign in to comment.