From 5cbf16f767dfe69bda9d02b38fea0230036d0435 Mon Sep 17 00:00:00 2001 From: Serhii Date: Fri, 15 Nov 2024 13:56:33 +0100 Subject: [PATCH] solving the task --- app/main.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/app/main.py b/app/main.py index 68287892..f3d80f40 100644 --- a/app/main.py +++ b/app/main.py @@ -2,5 +2,16 @@ def cache(func: Callable) -> Callable: - # Write your code here - pass + + tmp_cache = {} + + def inner(*args): + if args in tmp_cache: + print("Getting from cache") + return tmp_cache[args] + else: + print("Calculating new result") + result = func(*args) + tmp_cache[args] = result + return result + return inner