2022-12-05 20:50:37 +02:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
from useful import *
|
|
|
|
|
|
|
|
def stuff(l):
|
2022-12-05 21:30:08 +02:00
|
|
|
return next(iter(set(l[:len(l)//2]) & set(l[len(l)//2:])))
|
2022-12-05 20:50:37 +02:00
|
|
|
|
|
|
|
def points(c):
|
|
|
|
o = ord(c)
|
|
|
|
return 27 + o - ord('A') if o < ord('a') else 1 + o - ord('a')
|
|
|
|
|
2022-12-05 21:22:31 +02:00
|
|
|
def twuff(trip):
|
2022-12-05 21:30:08 +02:00
|
|
|
return next(iter(reduce(lambda a, b: a & b, (set(l) for l in trip))))
|
2022-12-05 21:22:31 +02:00
|
|
|
|
|
|
|
ls = lines(open(0))
|
|
|
|
print(sum(points(stuff(l)) for l in ls))
|
2022-12-05 21:30:08 +02:00
|
|
|
print(sum(points(twuff(l)) for l in batched(ls, 3)))
|