-
Notifications
You must be signed in to change notification settings - Fork 4
/
day-02.py
36 lines (33 loc) · 963 Bytes
/
day-02.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
with open('inputs/day-02.txt') as file:
rounds = file.read().split('\n')
# Part 1
outcomeP1 = {
'A X': 3+1,
'A Y': 6+2,
'A Z': 0+3,
'B X': 0+1,
'B Y': 3+2,
'B Z': 6+3,
'C X': 6+1,
'C Y': 0+2,
'C Z': 3+3,
}
resultP1 = sum([outcomeP1[x] for x in rounds])
print('Day 02 Part 1:', resultP1)
# Part 2
outcomeP2 = {
'A X': 0+3,
'A Y': 3+1,
'A Z': 6+2,
'B X': 0+1,
'B Y': 3+2,
'B Z': 6+3,
'C X': 0+2,
'C Y': 3+3,
'C Z': 6+1,
}
resultP2 = sum([outcomeP2[x] for x in rounds])
print('Day 02 Part 2:', resultP2)
# One-line Solutions
print('Day 02 Part 1:', sum([{'A X':3+1,'A Y':6+2,'A Z':0+3,'B X':0+1,'B Y':3+2,'B Z':6+3,'C X':6+1,'C Y':0+2,'C Z':3+3}[x] for x in open('inputs/day-02.txt').read().split('\n')]))
print('Day 02 Part 2:', sum([{'A X':0+3,'A Y':3+1,'A Z':6+2,'B X':0+1,'B Y':3+2,'B Z':6+3,'C X':0+2,'C Y':3+3,'C Z':6+1}[x] for x in open('inputs/day-02.txt').read().split('\n')]))