more cleaning

This commit is contained in:
Jake Pullen
2023-12-17 17:44:07 +00:00
parent c7107a4d44
commit 84ce884173
33 changed files with 40 additions and 40 deletions
+56
View File
@@ -0,0 +1,56 @@
with open(r'advent_of_code\2022\02\input.txt', 'r') as file:
input = file.read()
# print(input)
letter_map = {
'A': 'Rock',
'B': 'Paper',
'C': 'Scissors',
'X': 'Rock',
'Y': 'Paper',
'Z': 'Scissors'
}
score_map = {
'Rock': 1,
'Paper': 2,
'Scissors': 3
}
win_map = {
'win': 6,
'tie': 3,
'lose': 0
}
rounds= ['A Y', 'B X', 'C Z']
points = 0
for round in input.split('\n'):
if round == 'A X':
# Rock vs Rock
points += 4
if round == 'A Y':
# Rock vs Paper
points += 8
if round == 'A Z':
# Rock vs Scissors
points += 3
if round == 'B X':
# Paper vs Rock
points += 1
if round == 'B Y':
# Paper vs Paper
points += 5
if round == 'B Z':
# Paper vs Scissors
points += 9
if round == 'C X':
# Scissors vs Rock
points += 7
if round == 'C Y':
# Scissors vs Paper
points += 2
if round == 'C Z':
# Scissors vs Scissors
points += 6
print(points)
+77
View File
@@ -0,0 +1,77 @@
with open(r'advent_of_code\2022\02\input.txt', 'r') as file:
input = file.read()
# print(input)
letter_map = {
'A': 'Rock',
'B': 'Paper',
'C': 'Scissors',
}
decision_map = {
'X': 'loose',
'Y': 'draw',
'Z': 'win'
}
score_map = {
'Rock': 1,
'Paper': 2,
'Scissors': 3
}
win_map = {
'win': 6,
'tie': 3,
'lose': 0
}
rounds = ['A Y', 'B X', 'C Z']
points = 0
# first we need to decide if we need to win / loose or draw
for round in input.split('\n'):
if round[2] == 'X':
points += 0
# we need to loose
if round[0] == 'A':
# they played rock
# to loose we need to play scissors
points += 3
if round[0] == 'B':
# they played paper
# to loose we need to play rock
points += 1
if round[0] == 'C':
# they played scissors
# to loose we need to play paper
points += 2
if round[2] == 'Y':
points += 3
# we need to draw
if round[0] == 'A':
# they played rock
# we need to play rock
points += 1
if round[0] == 'B':
# they played paper
# we need to play paper
points += 2
if round[0] == 'C':
# they played scissors
# we need to play scissors
points += 3
if round[2] == 'Z':
points += 6
# we need to win
if round[0] == 'A':
# they played rock
# we need to play paper
points += 2
if round[0] == 'B':
# they played paper
# we need to play scissors
points += 3
if round[0] == 'C':
# they played scissors
# we need to play rock
points += 1
print(points)