2022: Day 1 - 4

This commit is contained in:
ngb
2022-12-04 07:27:32 +01:00
parent bb8f6e1e8a
commit 78279014e0
12 changed files with 6271 additions and 0 deletions

34
2022/day2_1.py Normal file
View File

@@ -0,0 +1,34 @@
# A = Rock = 1 = X
# B = Paper = 2 = Y
# C = Scissors = 3 = Z
score_map = {
'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
}
## Read input file
input = []
with open('day2_input.txt', 'r') as f:
for line in f.readlines():
input.append(line.strip())
# Solve problem
def run():
total = 0
for line in input:
total += score_map[line]
print(total)
if __name__ == '__main__':
run()