diff --git a/app/main.py b/app/main.py index 68287892..83ef43e5 100644 --- a/app/main.py +++ b/app/main.py @@ -1,6 +1,14 @@ -from typing import Callable +from typing import Callable, Any -def cache(func: Callable) -> Callable: - # Write your code here - pass +def cache(func: callable) -> Callable: + cache_result = {} + + def function_cache(*args) -> Any: + if args not in cache_result: + cache_result[*args] = func(*args) + print("Calculating new result") + else: + print("Getting from cache") + return cache_result[*args] + return function_cache