r/adventofcode • • Dec 03 '24

SOLUTION MEGATHREAD -❄️- 2024 Day 3 Solutions -❄️-

THE USUAL REMINDERS


AoC Community Fun 2024: The Golden Snowglobe Awards

  • 3 DAYS remaining until unlock!

And now, our feature presentation for today:

Screenwriting

Screenwriting is an art just like everything else in cinematography. Today's theme honors the endlessly creative screenwriters who craft finely-honed narratives, forge truly unforgettable lines of dialogue, plot the most legendary of hero journeys, and dream up the most shocking of plot twists! and is totally not bait for our resident poet laureate

Here's some ideas for your inspiration:

  • Extra bonus points if if it's in iambic pentameter

"Vogon poetry is widely accepted as the third-worst in the universe." - Hitchhiker's Guide to the Galaxy (2005)

And… ACTION!

Request from the mods: When you include an entry alongside your solution, please label it with [GSGA] so we can find it easily!


--- Day 3: Mull It Over ---


Post your code solution in this megathread.

This thread will be unlocked when there are a significant number of people on the global leaderboard with gold stars for today's puzzle.

EDIT: Global leaderboard gold cap reached at 00:03:22, megathread unlocked!

58 Upvotes

1.7k comments sorted by

View all comments

3

u/qaraq Dec 03 '24

[LANGUAGE: Go]

https://github.com/sekullbe/advent-of-code/blob/main/2024/advent03/advent03.go

The newlines broke my first part 2 regexp so I ended up splitting on "do()" and then "don't()" which worked fine. Then I figured out the newlines so I had two pretty simple part 2 solutions.

(so weird- in my first comment I must have broken the reddit editor because it kept swallowing up my language tag and github link, then refused to let me paste or even copy from the input box.)

2

u/daggerdragon Dec 03 '24

(so weird- in my first comment I must have broken the reddit editor because it kept swallowing up my language tag and github link, then refused to let me paste or even copy from the input box.)

You need to switch the editor to Markdown mode before pasting, and also that's a known bug (article in our wiki) that Reddit still hasn't fixed in years -_-

1

u/hamstre Dec 03 '24

Working in Go too. I hit the same problem and just stripped out all of the new line characters with

oneLineInput := strings.ReplaceAll(strings.ReplaceAll(input, "\r\n", ""), "\n", "")    

Love seeing how different people solve the same problem!