first commit
This commit is contained in:
commit
9615165024
21 files changed
+404
No files matched your search
@@ -0,0 +1,25 @@
|
||||
from functools import lru_cache
|
||||
|
||||
import functools
|
||||
import time
|
||||
|
||||
def time_calculation(f):
|
||||
@functools.wraps(f)
|
||||
def wrapper(*args, **kwargs):
|
||||
start = time.perf_counter()
|
||||
result = f(*args, **kwargs)
|
||||
end = time.perf_counter()
|
||||
print(f"Dauer: {end-start:.4f} Sekunden")
|
||||
return result
|
||||
|
||||
return wrapper
|
||||
|
||||
@time_calculation
|
||||
@lru_cache(maxsize=None)
|
||||
def ways(n):
|
||||
if n <= 2:
|
||||
return n
|
||||
return ways(n-1) + ways(n-2)
|
||||
|
||||
print(ways(40))
|
||||
|
||||
Reference in new issue
Block a user