-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathl2_2.py
64 lines (54 loc) · 1.31 KB
/
l2_2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
totscore = 0
inp = open('inputl2.txt')
rock = 'A'
paper = 'B'
scissors = 'C'
lose = 'X'
draw = 'Y'
win = 'Z'
# win_over_rock = paper
# win_over_paper = scissors
# win_over_scissors = rock
def val(char):
if char == 'A':
return 1
elif char == 'B':
return 2
elif char == 'C':
return 3
elif char == 'X':
return 0
elif char == 'Y':
return 3
elif char == 'Z':
return 6
else:
print("something went wrong")
for line in inp:
row = line.strip("\n\r").split(' ')
totscore += val(row[1])
if row[0] == rock:
if row[1] == lose:
totscore += val(scissors) #+ val(lose)
elif row[1] == draw:
totscore += val(rock) #+ val(draw)
elif row[1] == win:
totscore += val(paper) #+ val(win)
elif row[0] == paper:
if row[1] == lose:
totscore += val(rock)
elif row[1] == draw:
totscore += val(paper)
elif row[1] == win:
totscore += val(scissors)
elif row[0] == scissors:
if row[1] == lose:
totscore += val(paper)
elif row[1] == draw:
totscore += val(scissors)
elif row[1] == win:
totscore += val(rock)
else:
print("something went wrong")
print(totscore)
inp.close()