23 lines
557 B
Python
Executable File
23 lines
557 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)]
|
|
|
|
def wpn(a, b): # for b (that's us)
|
|
return 'XYZ'[[[2, 0, 1],
|
|
[0, 1, 2],
|
|
[1, 2, 0]][prd(a)][prd(b)]]
|
|
|
|
rounds = [[l[0], l[2]] for l in lines(open(0))]
|
|
print(sum(scores(b) + bonus(a, b) for a, b in rounds))
|
|
print(sum(scores(wpn(a, b)) + bonus(a, wpn(a, b)) for a, b in rounds))
|