From 37e1dc820a22ee7a1fba0366a3717f447c558e3e Mon Sep 17 00:00:00 2001 From: Mika Suhonen Date: Fri, 2 Dec 2022 11:08:54 +0200 Subject: [PATCH] First answer --- 02/b.py | 69 +++++++++++++++++++++++++-------------------------------- 1 file changed, 30 insertions(+), 39 deletions(-) diff --git a/02/b.py b/02/b.py index bfcf4fc..25d6b8d 100644 --- a/02/b.py +++ b/02/b.py @@ -3,52 +3,43 @@ import os f = open(os.path.dirname(__file__)+"/input.txt", "r") tot = 0 -i = 0 for l in f: l.strip() choices = l.split(" ") result = 'draw' v = choices[0] - o = choices[1] - print (v + " " + o) - - match v: - case 'A': - if o == 'Y': - result = 'win' - print("voitto") - if o =='Z': - result = 'loss' - print("tappio") - case 'B': - if o == 'X': - result = 'loss' - print("tappio") - if o == 'Z': - result = 'win' - print("voittko") - case 'C': - if o == 'X': - result = 'win' - print("voitto") - if o == 'Y': - result = 'loss' - print("tappio") + o = choices[1].strip() + + round = 0 + if v == 'A': + if o == 'Y': + result = 'win' + if o == 'Z': + result = 'loss' + if v == 'B': + if o == 'X': + result = 'loss' + if o == 'Z': + result = 'win' + if v == 'C': + if o == 'X': + result = 'win' + if o == 'Y': + result = 'loss' - match choices[1]: - case 'X': - tot = tot + 1 - case 'Y': - tot = tot + 2 - case 'Z': - tot = tot + 3 + if o == 'X': + round = round + 1 + if o == 'Y': + round = round + 2 + if o == 'Z': + round = round + 3 - if result == 'draw': - tot = tot + 3 + res = 3 + if result == 'loss': + res = 0 if result == 'win': - tot = tot + 6 - i = i + 1 - print(tot) + res = 6 + + tot = tot + round + res print(tot) -print(i)