-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
70 lines (61 loc) · 2.47 KB
/
Copy pathmain.py
File metadata and controls
70 lines (61 loc) · 2.47 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
from argparse import ArgumentParser
from os import system, name
from time import time
from AOC_Lib.SolutionBase import DateCode
from Runner.InputDownloader import test_downloader
from Runner.ReadmeFormatter import format_readme
from Runner.SolutionRunner import run_date_code
from Runner.SolutionTesting import test_all_days_multiprocessed
from Runner.Util import getLastDateCode
if __name__ == "__main__":
parser = ArgumentParser(
description="Run an advent of code trial(s). Runs the most recent day unless otherwise specified."
)
parser.add_argument("-a", action="store_true", help="Run all (cached)")
parser.add_argument("-d", nargs=2, help="Load and run the date code")
# parser.add_argument('-p', action='store_true', help=testAllIntelliParse.__doc__)
parser.add_argument(
"-t", action="store_true", help="test to see if downloader is working"
)
parser.add_argument("-r", action="store_true", help="run the readme formatter")
parser.add_argument("-c", action="store_true", help="clear console before running")
parser.add_argument(
"-u", action="store_true", help="append the new template to legacy code."
)
args = parser.parse_args()
if args.c is True:
# Clear console before running
system("cls" if name == "nt" else "clear")
elif args.t is True:
# Test Downloader
print("Testing Downloader")
if test_downloader:
print("Downloader is working")
else:
print("Downloader failed")
elif args.r is True:
format_readme()
elif args.a:
print("Running on all days (this may take some time)")
start_time = time()
test_all_days_multiprocessed()
end_time = time()
print("Took {} seconds".format(round(end_time - start_time, 1000)))
else:
do_uplift = bool(args.u)
# Run a particular day
if args.d is not None:
assert len(args.d) >= 2
dateCode = DateCode(int(args.d[0]), int(args.d[1]))
(part1Answer, part2Answer) = run_date_code(
dateCode, uplift_if_legacy=do_uplift
)
else:
dateCode = getLastDateCode()
print(f"Last dateCode resolved to {dateCode}")
(part1Answer, part2Answer) = run_date_code(
dateCode, uplift_if_legacy=do_uplift
)
print(f"Answer for day {dateCode}:")
print(f"Part 1: {part1Answer}")
print(f"Part 2: {part2Answer}")