Definitely a bit more involved for me. Also I forgot part 2 for day 2.

master
Ben Maurer 2022-12-07 14:44:14 -06:00
parent 1070f5197e
commit 0d716588a0
3 changed files with 18 additions and 5 deletions

View File

@ -16,10 +16,22 @@ round_result = {
"C Z":6, "C Z":6,
} }
round_result_part2 = {
"A X":3, #0 + 3
"B X":1, #0 + 1
"C X":2, #0 + 2
"A Y":4, #3 + 1
"B Y":5, #3 + 2
"C Y":6, #3 + 3
"A Z":8, #6 + 2
"B Z":9, #6 + 3
"C Z":7, #6 + 1
}
strategy_score = 0 strategy_score = 0
moves_list = puzzle_input.split('\n') moves_list = puzzle_input.split('\n')
for move in moves_list: for move in moves_list:
strategy_score = strategy_score + round_result[move] strategy_score = strategy_score + round_result_part2[move]
print(strategy_score) print(strategy_score)

View File

@ -31,6 +31,4 @@ for r, rucksack in enumerate(rucksacks):
badges_priority = badges_priority + ord(in_badge) - 38 badges_priority = badges_priority + ord(in_badge) - 38
print(f'These elves are carrying a total of {total_priority:,} (prioritized?) things. That\'s a lotta stuff.') print(f'These elves are carrying a total of {total_priority:,} (prioritized?) things. That\'s a lotta stuff.')
print(f'They\'re also v important with a total badge priority of {badges_priority:,}.') print(f'They\'re also v important with a total badge priority of {badges_priority:,}.')

View File

@ -18,7 +18,10 @@ for m,move in enumerate(moves):
column_to = int(move.split(',')[2])-1 column_to = int(move.split(',')[2])-1
column_from = int(move.split(',')[1])-1 column_from = int(move.split(',')[1])-1
moved_number = int(move.split(',')[0]) moved_number = int(move.split(',')[0])
cargo[column_to] = cargo[column_to] + list(reversed(cargo[column_from][-moved_number::])) # Part 1
# cargo[column_to] = cargo[column_to] + list(reversed(cargo[column_from][-moved_number::]))
# Part 2
cargo[column_to] = cargo[column_to] + cargo[column_from][-moved_number::]
cargo[column_from] = cargo[column_from][:-moved_number] cargo[column_from] = cargo[column_from][:-moved_number]
answer = [] answer = []