-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
28 lines (24 loc) · 879 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import importlib
import pkgutil
from day_base import Day
YEAR = 2023
if __name__ == '__main__':
# Import all the days in the days package
for (module_loader, name, ispkg) in pkgutil.iter_modules([str(YEAR)]):
importlib.import_module('.' + name, str(YEAR))
# Run all the run methods of the days
print("Initializing day classes and fetching input data from AoC site...")
percentage = 0
step_size = 100.0 / len(Day.__subclasses__())
days = []
for c in Day.__subclasses__():
days.append(c())
percentage += step_size
print(f"\r{percentage:3.0f}% done", end="")
print("\rFinished!\r\n")
for day in sorted(days, key=lambda day: day.day_nr):
try:
day.run()
except Exception as e:
print(f"Warning exception occurred for {day.__class__.__name__}: {e}")
print()