-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path10a.py
More file actions
35 lines (28 loc) · 691 Bytes
/
10a.py
File metadata and controls
35 lines (28 loc) · 691 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
32
33
34
35
#Advent of code 2020
# 07/16/21 day 10a
#import re
filename = "data10.txt"
file = open(filename)
filestr = file.read()
a_list = filestr.split("\n")
maxindex = len(a_list)
#print(a_list)
print(f"maxindex={maxindex}, maxcolumns={len(a_list[0])}")
num_list = list(map(int, a_list))
num_max = max(num_list)
num_min = min(num_list)
print(f"{num_list}, max={num_max}, min={num_min}")
sorted_list = sorted(num_list)
print(f"{sorted_list}")
diff1 = 0
diff3 = 0
prev = 0
for num in sorted_list:
if num - prev == 1:
diff1 += 1
if num - prev == 3:
diff3 += 1
prev = num
# for final adapter.
diff3 += 1
print(f"diff1={diff1}, diff3={diff3}, multiplied={diff1*diff3}")