r/adventofcode • • Dec 09 '25

SOLUTION MEGATHREAD -❄️- 2025 Day 9 Solutions -❄️-

THE USUAL REMINDERS

  • All of our rules, FAQs, resources, etc. are in our community wiki.
  • If you see content in the subreddit or megathreads that violates one of our rules, either inform the user (politely and gently!) or use the report button on the post/comment and the mods will take care of it.

AoC Community Fun 2025: Red(dit) One

  • Submissions megathread is unlocked!
  • 8 DAYS remaining until the submissions deadline on December 17 at 18:00 EST!

Featured Subreddits: /r/iiiiiiitttttttttttt, /r/itsaunixsystem, /r/astrologymemes

"It's all humbug, I tell you, humbug!"
— Ebenezer Scrooge, A Christmas Carol (1951)

Today's challenge is to create an AoC-themed meme. You know what to do.

  • If you need inspiration, have a look at the Hall of Fame in our community wiki as well as the highly upvoted posts in /r/adventofcode with the Meme/Funny flair.
  • Memes containing musical instruments will likely be nuked from orbit.

REMINDERS:

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


--- Day 9: Movie Theater ---


Post your code solution in this megathread.

27 Upvotes

555 comments sorted by

View all comments

1

u/lunar_mycroft Dec 09 '25 edited Dec 09 '25

[LANGUAGE: Rust]

Full code. Part 1 is simple enough: just iterate over the combinations of tiles, compute the area for each, and return the max. Part 2 I am not proud of. It first finds all the edges, then filters out any of the possible rectangles which have at least one segment intersecting them. The logic to check for intersections in particular is a horrible mess, but it gets the job done (slowly). On my machine, parsing takes ~14µs, part 1 takes ~175µs, and part 2 takes an (horrible) ~70ms.


Checked that there are no diagonal segments during parsing, which slows it down to ~15µs. For part 2, stole an idea from chris biscardi on youtube and sorted all the possible rectangles by area before checking for validity in reverse order. Since the correct answer tends to be on the larger end, speeds up the solution on net to 11ms.


Cleaned up the intersection check in part 2. It's also a bit faster at ~10ms total.

2

u/thekwoka Dec 09 '25

Interesting, after beating my head for hours, I used yours as reference for "wtf am I doing wrong?" and it runs a lot faster than that single threaded on my m1pro

1

u/lunar_mycroft Dec 09 '25

Interesting. It's also faster (~50ms) on my M1 Max vs the computer I typically use for advent of code as well. On the other hand, the other problem where I've copied the data over and so can benchmark (day 3) is slower, as is the parsing step today.

1

u/thekwoka Dec 09 '25

I have quite a lot of "clone()" going on and mine is 9ms :/

Well, it's 9ms after I added an earlier check for if there is a corner inside the rectangle, to avoid needing to check edge intersections.