Advent of Code 2021 - Day 10

preview_player
Показать описание
In this video series, I try to challenge myself with the Advent of Code trials. Each solution will be published to Github, and I hope you will learn something from my coding mistakes and perhaps send some code my way on how you have done these challenges. I know by reading code, so this is such an exciting thing for me.

Github repository:

Unlock unlimited opportunities with 50% off your first month of Coursera Plus

Get on the fast track to a career in cybersecurity. In this certificate program, you'll learn in-demand skills, and get AI training from Google experts. Learn at your own pace, no degree or experience required.

Join the channel to get access to more perks:

Or visit my blog at:

Outro music: Sanaas Scylla

#aoc2021 #advent #code
Рекомендации по теме
Комментарии
Автор

My solution used a very similar approach, although I structured the code a little more into functions. For part A, I have a function that calculates the "corruption score", with 0 being a non-corrupted input. So then I can just add up the results of the function. Then for part B, I skip over the lines that have a corruption score > 0, and calculate the "incomplete score" by processing the remainder of the stack. Overall pretty much the same as you did.

I did create an "Operator" class that, given the opening character, knows its own expected closing character. That felt like it cleaned up the mismatch checking a bit, as I just have to pop off the stack and compare it to the actual closing character from the input to see if it matches.

aaronperl