From 04ede97a4d3797ab45136bf6a0f20e80936302bb Mon Sep 17 00:00:00 2001 From: bogdAAAn1 Date: Tue, 17 Dec 2024 18:25:51 +0200 Subject: [PATCH] Solution --- app/main.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/app/main.py b/app/main.py index 68287892..5c66ad2d 100644 --- a/app/main.py +++ b/app/main.py @@ -2,5 +2,14 @@ def cache(func: Callable) -> Callable: - # Write your code here - pass + cached_data = {} + + def wrapper(*args) -> None: + if args in cached_data: + print("Getting from cache") + else: + print("Calculating new result") + cached_data[args] = func(*args) + return cached_data[args] + + return wrapper