aoc2022/d03/part1.py

17 lines
247 B
Python
Raw 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 line in sys.stdin:
(l,r) = line[:len(line)//2], line[len(line)//2:-1]
b = set(l) & set(r)
yield list(b)[0]
print(sum(p(c) for c in gen()))