-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathday2.py
63 lines (55 loc) · 1.11 KB
/
day2.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
#!/usr/bin/env python
f = open("ressources/day2.txt", "r")
lines = f.readlines()
score = 0
association = {
'A': 'X',
'B': 'Y',
'C': 'Z'
}
for line in lines:
opponentchoice = association[line[0]]
mychoice = line[2]
if mychoice == opponentchoice:
score += 3
if mychoice == 'X':
score += 1
if opponentchoice == 'Z':
score += 6
if mychoice == 'Y':
score += 2
if opponentchoice == 'X':
score += 6
if mychoice == 'Z':
score += 3
if opponentchoice == 'Y':
score += 6
print("Your Score is: {}".format(score))
score = 0
loss = {
'X': 3,
'Y': 1,
'Z': 2
}
draw = {
'X': 1,
'Y': 2,
'Z': 3
}
win = {
'X': 2,
'Y': 3,
'Z': 1
}
for line in lines:
opponentchoice = association[line[0]]
result = line[2]
if result == 'X':
score += loss[opponentchoice]
if result == 'Y':
score +=3
score += draw[opponentchoice]
if result == 'Z':
score +=6
score += win[opponentchoice]
print("Your Score is: {}".format(score))