AoC# 2024 - Day 3: Mull It Over
It’s Advent of Code time 🎄
Advent of Code is an Advent calendar of small programming puzzles for a variety of skill levels that can be solved in any programming language you like.
A delayed start to my attempt at Day 3 because I was catching up on much needed rest 😴
Dude, where’s the video?
I’m glad I tried making the daily attempt videos this year, but I’ve found that editing them takes a long time, and when I thought of my own preference as a viewer, I either want a speed-run style (like Jonathan’s), or a longer walk-through explanation.
Of these, I feel I’m better skilled for creating the latter 😉
Part 1 ⭐️
This looked to be best solved with regular expressions which I don’t use often, so it took a little tweaking but was solved pretty quickly. The easy to remember https://ihateregex.io helped with its visualisation 😄
Part 2 ⭐️
Initially I’d thought I could advance through the input with a current index, passing the substring between don't()
and do()
to the Part 1 RegEx, but this approach didn’t work.
I then wondered about extending the RegEx to include the commands and then looping through all of the matches which would be in order - this worked a treat.
I think my solution could be improved by using RegEx’s capture groups to pull out the x
and y
values.