Create aoc_utils
This commit is contained in:
parent
483788be60
commit
bef72df794
0
aoc_utils/__init__.py
Normal file
0
aoc_utils/__init__.py
Normal file
13
aoc_utils/constants.py
Normal file
13
aoc_utils/constants.py
Normal 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
13
aoc_utils/decorators.py
Normal 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
|
Loading…
Reference in New Issue
Block a user