-
Notifications
You must be signed in to change notification settings - Fork 0
/
day2.py
63 lines (40 loc) · 964 Bytes
/
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
# -*- coding: utf-8 -*-
"""
Created on Wed Dec 14 09:18:06 2022
@author: A200014490
"""
# Advent of Code Day 2
# get Input
with open("day2input.txt", 'r') as f:
_input = f.readlines()
# Part 1
res = 0
my_score = 0
value = {
'A': 1,
'B': 2,
'C': 3,
'X': 1,
'Y': 2,
'Z': 3
}
for line in _input:
enemy_move = line[0]
my_move = line[2]
difference = value[enemy_move] - value[my_move]
if (difference == 0):
# Draw
my_score += value[my_move] + 3
elif (difference == 2):
# Win
my_score += value[my_move] + 6
elif (difference == 1):
# Loss
my_score += value[my_move]
elif (difference == -1):
# Win
my_score += value[my_move] + 6
elif (difference == -2):
# Loss
my_score += value[my_move]
print(my_score)