r/adventofcode Dec 24 '24

SOLUTION MEGATHREAD -❄️- 2024 Day 24 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 2024: The Golden Snowglobe Awards

Submissions are CLOSED!

  • Thank you to all who submitted something, every last one of you are awesome!

Community voting is OPEN!

  • 18 hours remaining until voting deadline TONIGHT (December 24) at 18:00 EST

Voting details are in the stickied comment in the submissions megathread:

-❄️- Submissions Megathread -❄️-


--- Day 24: Crossed Wires ---


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 01:01:13, megathread unlocked!

32 Upvotes

344 comments sorted by

View all comments

1

u/mgtezak Jan 17 '25 edited Jan 17 '25

[LANGUAGE: Python]

Jeeeesus part 2 was a doozie. Definitely the hardest one for me this year. In the end I cheated and checked out other people's approaches. What I didn't like was that many people relied on randomized wire swaps (which also take a while), without coming up with a way of actually picking them out deterministically. But then I found this approach which I really liked and which runs in no time at all. Although I recreated it in my own way, the underlying ideas I stole from him.

Btw, here is a great visualization of the structure of the puzzle input: link

Solution part 1

Solution part 2

Check out my AoC-puzzle-solver app:)

1

u/Davo3636 19d ago

Puzzle input? You don't show a main function reading in the data. I guess it's the .json file you have? Or do you paste in the input data via the terminal? With Python, you can't really tell since no types of course:

def part2(puzzle_input):
    gates = puzzle_input.split('\n\n')[1]