aoc2022/d03/part2.py

19 lines
288 B
Python
Raw Permalink Normal View History

2022-12-03 15:01:59 +00:00
import sys
def p(c):
o = ord(c)
if o > 96:
return o-96
else:
return o-64+26
def gen():
for _ in range(100):
g1 = next(sys.stdin)[:-1]
g2 = next(sys.stdin)[:-1]
g3 = next(sys.stdin)[:-1]
b = set(g1) & set(g2) & set(g3)
yield list(b)[0]
print(sum(p(c) for c in gen()))