advent2022/two.py

18 lines
414 B
Python
Executable File

#!/usr/bin/env python3
from useful import *
def prd(c):
return (ord(c) - ord('A')) % 23
def scores(c):
return 1 + prd(c)
def bonus(a, b): # for b (that's us)
return [[3, 6, 0],
[0, 3, 6],
[6, 0, 3]][prd(a)][prd(b)]
rounds = [[l[0], l[2]] for l in lines(open(0))]
ic([[a, b, scores(b), bonus(a, b)] for a, b in rounds])
print(sum(scores(b) + bonus(a, b) for a, b in rounds))