You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

93 lines
1.3 KiB
Python

fi = open('in.txt', 'r')
RO, PO, SO = "A", "B", "C"
RM, PM, SM = "X", "Y", "Z"
W, D, L = 6, 3, 0
R, P, S = 1, 2, 3
x = fi.read().split('\n')
x2 = [z.split(" ") for z in x]
# 0 is the oppontent, 1 is you
score = 0
def w(o, m):
return (m == RM and o == SO) or ( m == PM and o == RO ) or (m == SM and o == PO)
def d(o, m):
return (m == RM and o == RO) or (m == PM and o == PO) or (m == SM and o == SO)
def p(x):
match x:
case "X":
return 1
case "Y":
return 2
case "Z":
return 3
case _:
return 0
for sc in x2[0:-1]:
if (w(sc[0], sc[1])):
score += W
elif (d(sc[0], sc[1])):
score += D
else:
score += L
score += p(sc[1])
print(score)
# A = rock, B = Paper, C = Scissors
def x(o):
match o:
case "A":
return SM
case "B":
return RM
case "C":
return PM
case _:
return ""
def d2(o):
match o:
case "A":
return RM
case "B":
return PM
case "C":
return SM
case _:
return ""
def w2(o):
match o:
case "A":
return PM
case "B":
return SM
case "C":
return RM
case _:
return ""
score2 = 0
for sc in x2[0:-1]:
match sc[1]:
case "X":
resu = x(sc[0])
score2 += 0
case "Y":
resu = d2(sc[0])
score2 += 3
case "Z":
resu = w2(sc[0])
score2 += 6
score2 += p(resu)
print(score2)