summaryrefslogtreecommitdiffstats
path: root/2.py
blob: abcd27feb96c725224385040a551b8127e9115f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
with open('2.in') as f:
    inp = []
    for line in f:
        a, b = line.rstrip().split()
        inp.append((ord(a) - ord('A'), ord(b) - ord('X')))
def shape_score(me):
    return me + 1
def outcome_score(opp, me):
    return (3 - opp + me + 1) % 3 * 3
def p1(opp, me):
    return shape_score(me) + outcome_score(opp, me)
print(sum(p1(a, b) for a, b in inp))
def shape_for_outcome(opp, outcome):
    return (3 + opp + outcome + 2) % 3
def p2(opp, outcome):
    me = shape_for_outcome(opp, outcome)
    return p1(opp, me)
print(sum(p2(a, b) for a, b in inp))