From d9a97e9bf28cf91f1a7e57f1298b7c742e25ed56 Mon Sep 17 00:00:00 2001 From: Tomasz Kramkowski Date: Wed, 7 Dec 2022 12:57:36 +0000 Subject: days 1-7 --- 2.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 2.py (limited to '2.py') diff --git a/2.py b/2.py new file mode 100644 index 0000000..abcd27f --- /dev/null +++ b/2.py @@ -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)) -- cgit v1.2.3-54-g00ecf