blob: b499db3623a118950a813ba1aae8c12ecaa6e39f (
plain)
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
|
#!/usr/bin/env python3
import math
import time
score1 = 0
score2 = 0
# filename = "in/day02.ref"
filename = "in/day02.pzl"
with open(filename) as f:
for line in f:
line = line.strip()
abc, xyz = line[0], line[2]
if abc == 'A':
abc = 1
elif abc == 'B':
abc = 2
elif abc == 'C':
abc = 3
else:
print('ERROR')
if xyz == 'X':
xyz = 1
elif xyz == 'Y':
xyz = 2
elif xyz == 'Z':
xyz = 3
else:
print('ERROR')
s1 = 0
if abc == xyz:
print('draw')
s1 = 3 + xyz
# elif ((xyz + 1)%3) + 1 == abc:
elif abc%3 + 1 == xyz:
print('win')
s1 = 6 + xyz
else:
print('lose')
s1 = 0 + xyz
print('s1', s1)
score1 += s1
if xyz == 1:
# lose
s2 = 0 + (abc-1 + 2)%3 + 1
elif xyz == 2:
# draw
s2 = 3 + abc
elif xyz == 3:
# win
s2 = 6 + (abc-1 + 1)%3 + 1
print('s2', s2)
score2 += s2
print('score1', score1)
print('score2', score2)
|