aoc2022/d03/part1.py

17 lines
247 B
Python

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()))