-
Notifications
You must be signed in to change notification settings - Fork 0
/
day02.py
executable file
·58 lines (45 loc) · 1.53 KB
/
day02.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
"""
Part_1:
elf: A for Rock, B for Paper, and C for Scissors.
you: X for Rock, Y for Paper, and Z for Scissors
score calculation: 1 for Rock, 2 for Paper, and 3 for Scissors +
outcome of the round (0 if you lost, 3 if the round was a draw, and 6 if you won)
Part_2:
second columns indicates now the output: X lose, Y draw, Z win, so find you had chosen
"""
from src.common.utils import SolverFunctions
title = 'Day 2: Rock Paper Scissors'
parser_method = 'str_split'
handle_data = 'lines'
class SolveTheDay(SolverFunctions):
@classmethod
def level_1(cls, data):
answer = 0
for line in data:
left, right = line
left = "ABC".index(left)
right = "XYZ".index(right)
answer += right + 1
match (right - left) % 3:
case 1:
answer += 6
case 0:
answer += 3
return answer
return
@classmethod
def level_2(cls, data):
answer = 0
for line in data:
left, right = line
left = "ABC".index(left)
match right:
case "X":
answer += (left - 1) % 3 + 1
case "Y":
answer += 3
answer += left + 1
case "Z":
answer += 6
answer += (left + 1) % 3 + 1
return answer