day10 pt1
This commit is contained in:
26
day10/day10.py
Normal file
26
day10/day10.py
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
def part1():
|
||||||
|
file = open("input.txt")
|
||||||
|
lines = [int(i) for i in file.readlines()]
|
||||||
|
|
||||||
|
lines = sorted(lines)
|
||||||
|
|
||||||
|
diffs = {1: 0, 3: 0}
|
||||||
|
|
||||||
|
diffs[lines[0]] += 1
|
||||||
|
lines.append(max(lines) + 3)
|
||||||
|
|
||||||
|
for i in range(1, len(lines)):
|
||||||
|
diff = lines[i] - lines[i - 1]
|
||||||
|
diffs[diff] += 1
|
||||||
|
|
||||||
|
print("Part 1 %d " % (diffs[1] * diffs[3]))
|
||||||
|
|
||||||
|
|
||||||
|
def part2():
|
||||||
|
file = open("input.txt")
|
||||||
|
lines = [int(i) for i in file.readlines()]
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
part1()
|
||||||
|
part2()
|
||||||
90
day10/input.txt
Normal file
90
day10/input.txt
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
114
|
||||||
|
51
|
||||||
|
122
|
||||||
|
26
|
||||||
|
121
|
||||||
|
90
|
||||||
|
20
|
||||||
|
113
|
||||||
|
8
|
||||||
|
138
|
||||||
|
57
|
||||||
|
44
|
||||||
|
135
|
||||||
|
76
|
||||||
|
134
|
||||||
|
15
|
||||||
|
21
|
||||||
|
119
|
||||||
|
52
|
||||||
|
118
|
||||||
|
107
|
||||||
|
99
|
||||||
|
73
|
||||||
|
72
|
||||||
|
106
|
||||||
|
41
|
||||||
|
129
|
||||||
|
83
|
||||||
|
19
|
||||||
|
66
|
||||||
|
132
|
||||||
|
56
|
||||||
|
32
|
||||||
|
79
|
||||||
|
27
|
||||||
|
115
|
||||||
|
112
|
||||||
|
58
|
||||||
|
102
|
||||||
|
64
|
||||||
|
50
|
||||||
|
2
|
||||||
|
39
|
||||||
|
3
|
||||||
|
77
|
||||||
|
85
|
||||||
|
103
|
||||||
|
140
|
||||||
|
28
|
||||||
|
133
|
||||||
|
78
|
||||||
|
34
|
||||||
|
13
|
||||||
|
61
|
||||||
|
25
|
||||||
|
35
|
||||||
|
89
|
||||||
|
40
|
||||||
|
7
|
||||||
|
24
|
||||||
|
33
|
||||||
|
96
|
||||||
|
108
|
||||||
|
71
|
||||||
|
11
|
||||||
|
128
|
||||||
|
92
|
||||||
|
111
|
||||||
|
55
|
||||||
|
80
|
||||||
|
91
|
||||||
|
31
|
||||||
|
70
|
||||||
|
101
|
||||||
|
14
|
||||||
|
18
|
||||||
|
12
|
||||||
|
4
|
||||||
|
84
|
||||||
|
125
|
||||||
|
120
|
||||||
|
100
|
||||||
|
65
|
||||||
|
86
|
||||||
|
93
|
||||||
|
67
|
||||||
|
139
|
||||||
|
1
|
||||||
|
47
|
||||||
|
38
|
||||||
Reference in New Issue
Block a user