-
Notifications
You must be signed in to change notification settings - Fork 0
/
day2.py
67 lines (63 loc) · 1.72 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
64
65
66
67
class day2:
def __init__(self) -> None:
pass
def star1(self, input):
rounds = input.split("\n")
total = 0
for round in rounds:
score = 0
match round:
case "A X":
score = 4
case "A Y":
score = 8
case "A Z":
score = 3
case "B X":
score = 1
case "B Y":
score = 5
case "B Z":
score = 9
case "C X":
score = 7
case "C Y":
score = 2
case "C Z":
score = 6
total += score
print(f"Total score is {total}")
return total
def star2(self, input):
rounds = input.split("\n")
total = 0
for round in rounds:
score = 0
match round:
case "A X":
score = 3
case "A Y":
score = 4
case "A Z":
score = 8
case "B X":
score = 1
case "B Y":
score = 5
case "B Z":
score = 9
case "C X":
score = 2
case "C Y":
score = 6
case "C Z":
score = 7
total += score
print(f"Total score is {total}")
return total
if __name__ == '__main__':
with open("input/day2.star1") as f:
input = f.read()
d2 = day2()
d2.star1(input)
d2.star2(input)