This commit is contained in:
DUEFON 2022-12-05 20:22:31 +01:00 committed by Eivind Øksnevad
parent f00c25db26
commit e0b63fb15a
1 changed files with 10 additions and 2 deletions

View File

@ -9,5 +9,13 @@ 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))))
def twuff(trip):
d = [{x: True for x in l} for l in trip[:2]]
return next(c for c in trip[2] if c in d[0] and c in d[1])
def trips(ls):
return [[ls[i], ls[i+1], ls[i+2]] for i in range(0, len(ls), 3)]
ls = lines(open(0))
print(sum(points(stuff(l)) for l in ls))
print(sum(points(twuff(l)) for l in trips(ls)))