diff --git a/aoc_utils/__init__.py b/aoc_utils/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/aoc_utils/constants.py b/aoc_utils/constants.py new file mode 100644 index 0000000..77ec03b --- /dev/null +++ b/aoc_utils/constants.py @@ -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) +] \ No newline at end of file diff --git a/aoc_utils/decorators.py b/aoc_utils/decorators.py new file mode 100644 index 0000000..a6b5c71 --- /dev/null +++ b/aoc_utils/decorators.py @@ -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 \ No newline at end of file