First answer

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

45
02/b.py
View File

@@ -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)
o = choices[1].strip()
match v:
case 'A':
round = 0
if v == 'A':
if o == 'Y':
result = 'win'
print("voitto")
if o =='Z':
if o == 'Z':
result = 'loss'
print("tappio")
case 'B':
if v == 'B':
if o == 'X':
result = 'loss'
print("tappio")
if o == 'Z':
result = 'win'
print("voittko")
case 'C':
if v == 'C':
if o == 'X':
result = 'win'
print("voitto")
if o == 'Y':
result = 'loss'
print("tappio")
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)