Skip to content

Commit

Permalink
'Solution'
Browse files Browse the repository at this point in the history
  • Loading branch information
Dizatvarska committed Nov 13, 2024
1 parent 59d4bd5 commit b27901d
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions app/main.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
from typing import Callable, Any


def cache(func: Callable) -> Callable:
def cache(numero: int) -> Any:
def wrapper(*args, **kwargs) -> Any:
result = func(*args, **kwargs)
return result
def inner(func: Callable) -> Any:
results = []
for _ in range(numero):
results.append(func(*args, **kwargs))
for result in results:
if results.count(result) > 1:
print(f"Getting from cache {result}")
else:
print(f"Calculating new result {result}")
return inner
return wrapper

0 comments on commit b27901d

Please sign in to comment.