From 08b0b8210080061467b071e7157ac0c044b89360 Mon Sep 17 00:00:00 2001 From: Mika Suhonen Date: Fri, 2 Dec 2022 12:27:04 +0200 Subject: [PATCH] Answer 2 --- 02/b.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/02/b.py b/02/b.py index 25d6b8d..62da94f 100644 --- a/02/b.py +++ b/02/b.py @@ -3,6 +3,8 @@ import os f = open(os.path.dirname(__file__)+"/input.txt", "r") tot = 0 +tot2 = 0 + for l in f: l.strip() choices = l.split(" ") @@ -11,21 +13,46 @@ for l in f: o = choices[1].strip() round = 0 + round2 = 0 + if v == 'A': + if o == 'X': + round2 = 3 if o == 'Y': result = 'win' + round2 = 1 if o == 'Z': result = 'loss' + round2=2 + if v == 'B': if o == 'X': result = 'loss' + round2 = 1 + if o == 'Y': + round2 = 2 if o == 'Z': result = 'win' + round2 = 3 + if v == 'C': if o == 'X': result = 'win' + round2 = 2 if o == 'Y': result = 'loss' + round2 = 3 + if o == 'Z': + round2 = 1 + + if o == 'X': + round2 = round2 + 0 + if o == 'Y': + round2 = round2 + 3 + if o == 'Z': + round2 = round2 + 6 + + tot2 = tot2 + round2 if o == 'X': round = round + 1 @@ -43,3 +70,4 @@ for l in f: tot = tot + round + res print(tot) +print(tot2)