-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsanta.py
68 lines (58 loc) · 1.88 KB
/
santa.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
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
from aocd import submit
import argparse
debug = False
class bcolors:
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKCYAN = '\033[96m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
RED = '\033[31m'
FAIL = '\033[91m'
ENDC = '\033[0m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
def nei(x,y):
neigh_2d_4 = ((x-1,y), (x+1,y), (x, y-1), (x, y+1))
neigh_2d_5 = neigh_2d_4 + ((x,y),)
neigh_2d_4_skew = ((x-1,y-1), (x+1,y-1), (x-1, y+1), (x+1, y+1))
neigh_2d_8 = neigh_2d_4 + neigh_2d_4_skew
neigh_2d_9 = neigh_2d_8 + ((x,y),)
return neigh_2d_9
def sdf(*args):
if len(args)==0:
args = [""]
if debug:
print(*args)
def bake_main(script_name, p1, p2):
def main():
day = script_name.replace("t", "").replace(".py", "")
print(day)
parser = argparse.ArgumentParser()
parser.add_argument("-d", "--debug", action="store_true", help="Enable debug")
defname = f"p{day}.in"
parser.add_argument(
"path", nargs="?", default=defname, help="Path to the input file"
)
parser.add_argument("-p1", action="store_true", help="submit p1")
parser.add_argument("-p2", action="store_true", help="submit p2")
parser.add_argument("--year", type=int, default=None, help="select year")
args = parser.parse_args()
global debug
debug = args.debug
res = p1(args)
if args.p1:
submit(res, part="a", day=int(day), year=args.year)
res = p2(args)
if args.p2:
submit(res, part="b", day=int(day), year=args.year)
# run(args)
return main
def bake_main2():
def main():
parser = argparse.ArgumentParser()
parser.add_argument("-d", "--debug", action="store_true", help="Enable debug")
args = parser.parse_args()
global debug
debug = args.debug
return main