diff options
Diffstat (limited to '2.py')
-rw-r--r-- | 2.py | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -0,0 +1,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)) |