Skip to content

Commit 358cc82

Browse files
committed
Add Day10 solution
1 parent 64eea61 commit 358cc82

File tree

2 files changed

+127
-0
lines changed

2 files changed

+127
-0
lines changed

day10/day10.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
def count_possibilities_dp(adapters):
2+
dp_array = [1] + [0 for _ in range(adapters[-1])]
3+
print(len(dp_array))
4+
for i, e in enumerate(adapters):
5+
for i in range(max(0 ,e-3), e):
6+
dp_array[e] += dp_array[i]
7+
print(dp_array)
8+
9+
10+
def main():
11+
f=open("input", "r")
12+
lines = sorted([0] + [int(line.strip()) for line in f.readlines()])
13+
lines.append(lines[-1]+3)
14+
print(lines)
15+
16+
ones=0
17+
threes=1
18+
for ind, i in enumerate(lines[:-1]):
19+
if lines[ind+1] - i == 1:
20+
# print("one: {} {}".format(i, lines[ind+1]))
21+
ones+=1
22+
elif lines[ind+1] - i == 3:
23+
# print("threes " + str())
24+
threes+=1
25+
print(ones)
26+
print(threes)
27+
print(ones*threes)
28+
29+
print(count_possibilities_dp(lines))
30+
31+
32+
33+
main()

day10/input

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
38
2+
23
3+
31
4+
16
5+
141
6+
2
7+
124
8+
25
9+
37
10+
147
11+
86
12+
150
13+
99
14+
75
15+
81
16+
121
17+
93
18+
120
19+
96
20+
55
21+
48
22+
58
23+
108
24+
22
25+
132
26+
62
27+
107
28+
54
29+
69
30+
51
31+
7
32+
134
33+
143
34+
122
35+
28
36+
60
37+
123
38+
82
39+
95
40+
14
41+
6
42+
106
43+
41
44+
131
45+
109
46+
90
47+
112
48+
1
49+
103
50+
44
51+
127
52+
9
53+
83
54+
59
55+
117
56+
8
57+
140
58+
151
59+
89
60+
35
61+
148
62+
76
63+
100
64+
114
65+
130
66+
19
67+
72
68+
36
69+
133
70+
12
71+
34
72+
46
73+
15
74+
45
75+
87
76+
144
77+
80
78+
13
79+
142
80+
149
81+
88
82+
94
83+
61
84+
154
85+
24
86+
66
87+
113
88+
5
89+
73
90+
79
91+
74
92+
65
93+
137
94+
47

0 commit comments

Comments
 (0)