aoc2022/3pt2.py
2022-12-13 19:25:38 +09:00

11 lines
No EOL
309 B
Python

with open("input3.txt") as f:
a = dict(zip(map(chr,(list(range(97,123))+list(range(65,91)))),range(1,53)))
s = 0
h = []
for line in f.readlines():
h.append(set(line.strip()))
if len(h) < 3:
continue
s += a[(h[0]&h[1]&h[2]).pop()]
h = []
print(s)