advent2022/three.py

14 lines
354 B
Python
Executable File

#!/usr/bin/env python3
from useful import *
def stuff(l):
d = {x: True for x in l[:len(l)//2]}
return next(x for x in l[len(l)//2:] if d.get(x))
def points(c):
o = ord(c)
return 27 + o - ord('A') if o < ord('a') else 1 + o - ord('a')
#ic([points(stuff(l)) for l in lines(open(0))])
print(sum(points(stuff(l)) for l in lines(open(0))))