-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathday_10a.py
More file actions
31 lines (27 loc) · 699 Bytes
/
day_10a.py
File metadata and controls
31 lines (27 loc) · 699 Bytes
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
#!/usr/bin/env python3
def main():
f = open("../input/day_10_input")
jolts = list()
for line in f:
line = line.strip().replace("\n", "").replace("\r", "")
jolts.append(int(line))
jolts.sort()
diff_1 = 0
diff_2 = 0
diff_3 = 0
for i in range(1, len(jolts)):
diff = jolts[i] - jolts[i - 1]
if diff == 1:
diff_1 += 1
elif diff == 2:
diff_2 += 1
elif diff == 3:
diff_3 += 1
else:
print("WTH")
diff_1 += 1 # from outlet to first
diff_3 += 1 # to built in adapter
print(diff_1 * diff_3)
return diff_1 * diff_3
if __name__ == "__main__":
main()