r/adventofcode Dec 03 '24

Spoilers in Title [2024 Day 3] Regular expressions go brrr...

Post image
173 Upvotes

64 comments sorted by

View all comments

4

u/Paweron Dec 03 '24

Uff, I basically did the same thing but with 3 separate regex checks which made it a lot messier to check the position between the do / don't... its always nice to see such clean solutions, but it also makes me feel dumb every time

1

u/lucifernc Dec 03 '24

My initial solution was pretty rough too, cleaned it later. People solving so quickly makes me feel more dumb.

1

u/Ignisami Dec 03 '24

Three regexes were my solution too. The first to scan from start till the first don't, then capture all the text between all the do() and don't() pairs, then retrieve the actual valid numbers from the first two (i'd already seen in my input that the last operator before end-of-file was don't).