[py] Port 2020_10
This commit is contained in:
parent
81945a973d
commit
bd2dd9a4f9
5 changed files with 149 additions and 9 deletions
102
inputs/2020_10
Normal file
102
inputs/2020_10
Normal file
|
|
@ -0,0 +1,102 @@
|
||||||
|
103
|
||||||
|
131
|
||||||
|
121
|
||||||
|
151
|
||||||
|
118
|
||||||
|
12
|
||||||
|
7
|
||||||
|
2
|
||||||
|
90
|
||||||
|
74
|
||||||
|
160
|
||||||
|
58
|
||||||
|
15
|
||||||
|
83
|
||||||
|
153
|
||||||
|
140
|
||||||
|
166
|
||||||
|
1
|
||||||
|
148
|
||||||
|
33
|
||||||
|
165
|
||||||
|
39
|
||||||
|
100
|
||||||
|
135
|
||||||
|
68
|
||||||
|
77
|
||||||
|
25
|
||||||
|
9
|
||||||
|
54
|
||||||
|
94
|
||||||
|
101
|
||||||
|
55
|
||||||
|
141
|
||||||
|
22
|
||||||
|
97
|
||||||
|
35
|
||||||
|
57
|
||||||
|
117
|
||||||
|
102
|
||||||
|
64
|
||||||
|
109
|
||||||
|
114
|
||||||
|
56
|
||||||
|
51
|
||||||
|
125
|
||||||
|
82
|
||||||
|
154
|
||||||
|
142
|
||||||
|
155
|
||||||
|
45
|
||||||
|
75
|
||||||
|
158
|
||||||
|
120
|
||||||
|
5
|
||||||
|
19
|
||||||
|
61
|
||||||
|
34
|
||||||
|
128
|
||||||
|
106
|
||||||
|
88
|
||||||
|
84
|
||||||
|
137
|
||||||
|
96
|
||||||
|
136
|
||||||
|
27
|
||||||
|
6
|
||||||
|
21
|
||||||
|
89
|
||||||
|
69
|
||||||
|
162
|
||||||
|
112
|
||||||
|
127
|
||||||
|
119
|
||||||
|
161
|
||||||
|
38
|
||||||
|
42
|
||||||
|
134
|
||||||
|
20
|
||||||
|
81
|
||||||
|
48
|
||||||
|
73
|
||||||
|
87
|
||||||
|
26
|
||||||
|
95
|
||||||
|
146
|
||||||
|
113
|
||||||
|
76
|
||||||
|
32
|
||||||
|
70
|
||||||
|
8
|
||||||
|
18
|
||||||
|
67
|
||||||
|
124
|
||||||
|
80
|
||||||
|
93
|
||||||
|
29
|
||||||
|
126
|
||||||
|
147
|
||||||
|
28
|
||||||
|
152
|
||||||
|
145
|
||||||
|
159
|
||||||
|
|
@ -2,10 +2,12 @@ import sys
|
||||||
import argparse
|
import argparse
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
from .y2020 import d10
|
||||||
from .y2021 import d14
|
from .y2021 import d14
|
||||||
from .y2022 import d01, d02, d03, d04
|
from .y2022 import d01, d02, d03, d04
|
||||||
|
|
||||||
DAYS = {
|
DAYS = {
|
||||||
|
"2020_10": y2020.d10.solve,
|
||||||
"2021_14": y2021.d14.solve,
|
"2021_14": y2021.d14.solve,
|
||||||
"2022_01": y2022.d01.solve,
|
"2022_01": y2022.d01.solve,
|
||||||
"2022_02": y2022.d02.solve,
|
"2022_02": y2022.d02.solve,
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,5 @@
|
||||||
import sys
|
def solve(inputstr):
|
||||||
|
values = list(sorted(int(i) for i in inputstr.splitlines()))
|
||||||
def main(path):
|
|
||||||
with open(path) as f:
|
|
||||||
values = list(sorted(int(i) for i in f))
|
|
||||||
values.append(max(values) + 3)
|
values.append(max(values) + 3)
|
||||||
|
|
||||||
diffs = [y - x for x, y in zip([0] + values, values)]
|
diffs = [y - x for x, y in zip([0] + values, values)]
|
||||||
|
|
@ -12,6 +9,3 @@ def main(path):
|
||||||
for adapter in values:
|
for adapter in values:
|
||||||
combinations[adapter] = sum(combinations[max(0, adapter - 3) : adapter])
|
combinations[adapter] = sum(combinations[max(0, adapter - 3) : adapter])
|
||||||
print(f"Part 2: {combinations[-1]}")
|
print(f"Part 2: {combinations[-1]}")
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main(sys.argv[1])
|
|
||||||
11
sample_inputs/2020_10.01
Normal file
11
sample_inputs/2020_10.01
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
16
|
||||||
|
10
|
||||||
|
15
|
||||||
|
5
|
||||||
|
1
|
||||||
|
11
|
||||||
|
7
|
||||||
|
19
|
||||||
|
6
|
||||||
|
12
|
||||||
|
4
|
||||||
31
sample_inputs/2020_10.02
Normal file
31
sample_inputs/2020_10.02
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
28
|
||||||
|
33
|
||||||
|
18
|
||||||
|
42
|
||||||
|
31
|
||||||
|
14
|
||||||
|
46
|
||||||
|
20
|
||||||
|
48
|
||||||
|
47
|
||||||
|
24
|
||||||
|
23
|
||||||
|
49
|
||||||
|
45
|
||||||
|
19
|
||||||
|
38
|
||||||
|
39
|
||||||
|
11
|
||||||
|
1
|
||||||
|
32
|
||||||
|
25
|
||||||
|
35
|
||||||
|
8
|
||||||
|
17
|
||||||
|
7
|
||||||
|
9
|
||||||
|
4
|
||||||
|
2
|
||||||
|
34
|
||||||
|
10
|
||||||
|
3
|
||||||
Loading…
Add table
Add a link
Reference in a new issue