-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgame.py
47 lines (41 loc) · 1.1 KB
/
game.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
class Game():
def __init__(self, input):
self.input = input
def calculate(self):
input = self.input.split('\n')
points_dict = {
"A X": 4,
"A Y": 8,
"A Z": 3,
"B X": 1,
"B Y": 5,
"B Z": 9,
"C X": 7,
"C Y": 2,
"C Z": 6,
}
for line in input:
if line == "":
continue
input[input.index(line)] = points_dict[line]
input = filter(lambda x: x != "", input)
return sum(input)
def calculate_p2(self):
input = self.input.split('\n')
points_dict = { # X -> Lose, Y -> Draw, Z -> Win
"A X": 3,
"A Y": 4,
"A Z": 8,
"B X": 1,
"B Y": 5,
"B Z": 9,
"C X": 2,
"C Y": 6,
"C Z": 7,
}
for line in input:
if line == "":
continue
input[input.index(line)] = points_dict[line]
input = filter(lambda x: x != "", input)
return sum(input)