-
Notifications
You must be signed in to change notification settings - Fork 0
/
template.py
93 lines (60 loc) · 1.69 KB
/
template.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/usr/bin/env python3
import re
import sys
from collections import Counter, defaultdict, deque
from itertools import permutations, combinations, product
import itertools
import aocd
flatten = itertools.chain.from_iterable
is_sample = False
DAY = # TODO: change me
YEAR = 2019
##########################################################################
def main(A):
# Solve part 1
def part1():
pass
res = part1()
submit_1(res)
# Solve part 2
def part2():
pass
res = part2()
submit_2(res)
##########################################################################
def parse_token(x):
#x = int(x)
return x
def parse_line(line):
line = line.split()
#line = re.findall(r'\d+', line)
#line = re.findall(r'[-+]?\d+', line)
line = [parse_token(x) for x in line]
# One token per line
line = line[0]
return line
def parse_input(A):
A = A.strip()
A = A.splitlines()
A = [parse_line(line) for line in A]
# One line per input
A = A[0]
return A
##########################################################################
def submit_1(res):
print('Part 1', res)
if not is_sample and not input("skip? "):
puzzle.answer_a = res
def submit_2(res):
print('Part 2', res)
if not is_sample and not input("skip? "):
puzzle.answer_b = res
##########################################################################
if __name__ == '__main__':
if len(sys.argv) >= 2 and sys.argv[1].startswith('s'):
A = open('sample.txt').read()
is_sample = True
else:
puzzle = aocd.models.Puzzle(day=DAY, year=YEAR)
A = puzzle.input_data
main(parse_input(A))