First answer

This commit is contained in:
2022-12-02 11:08:54 +02:00
parent a4cf4d6a4a
commit 37e1dc820a

69
02/b.py
View File

@@ -3,52 +3,43 @@ import os
f = open(os.path.dirname(__file__)+"/input.txt", "r") f = open(os.path.dirname(__file__)+"/input.txt", "r")
tot = 0 tot = 0
i = 0
for l in f: for l in f:
l.strip() l.strip()
choices = l.split(" ") choices = l.split(" ")
result = 'draw' result = 'draw'
v = choices[0] v = choices[0]
o = choices[1] o = choices[1].strip()
print (v + " " + o)
round = 0
match v: if v == 'A':
case 'A': if o == 'Y':
if o == 'Y': result = 'win'
result = 'win' if o == 'Z':
print("voitto") result = 'loss'
if o =='Z': if v == 'B':
result = 'loss' if o == 'X':
print("tappio") result = 'loss'
case 'B': if o == 'Z':
if o == 'X': result = 'win'
result = 'loss' if v == 'C':
print("tappio") if o == 'X':
if o == 'Z': result = 'win'
result = 'win' if o == 'Y':
print("voittko") result = 'loss'
case 'C':
if o == 'X':
result = 'win'
print("voitto")
if o == 'Y':
result = 'loss'
print("tappio")
match choices[1]: if o == 'X':
case 'X': round = round + 1
tot = tot + 1 if o == 'Y':
case 'Y': round = round + 2
tot = tot + 2 if o == 'Z':
case 'Z': round = round + 3
tot = tot + 3
if result == 'draw': res = 3
tot = tot + 3 if result == 'loss':
res = 0
if result == 'win': if result == 'win':
tot = tot + 6 res = 6
i = i + 1
print(tot) tot = tot + round + res
print(tot) print(tot)
print(i)