Create aoc_utils

This commit is contained in:
augustin64 2023-12-23 15:28:25 +01:00
parent 483788be60
commit bef72df794
3 changed files with 26 additions and 0 deletions

0
aoc_utils/__init__.py Normal file
View File

13
aoc_utils/constants.py Normal file
View File

@ -0,0 +1,13 @@
arrows_dir ={
'^': (-1, 0),
'v': (1, 0),
'<': (0, -1),
'>': (0, 1)
}
cardinal_dir = [
(1, 0),
(-1,0),
(0, 1),
(0, -1)
]

13
aoc_utils/decorators.py Normal file
View File

@ -0,0 +1,13 @@
from functools import cache, wraps
import time
def timeit(func):
@wraps(func)
def timeit_wrapper(*args, **kwargs):
start_time = time.perf_counter()
result = func(*args, **kwargs)
end_time = time.perf_counter()
total_time = end_time - start_time
print(f'===== {func.__name__}: {total_time:.4f}s =====')
return result
return timeit_wrapper