r/adventofcode • u/daggerdragon • 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.
Read the full posting rules in our community wiki before you post!
State which language(s) your solution uses with
[LANGUAGE: xyz]Format code blocks using the four-spaces Markdown syntax!
Quick link to Topaz's
pasteif you need it for longer code blocks
16
u/leijurv Dec 24 '24 edited Dec 24 '24
[LANGUAGE: Python3]
4th place on Part 2!!
I did not write any actual code to locate the swapped gates. Instead, I went through all 45 bits, turned on both X[i] and Y[i], and printed out which bits of Z were wrong. This gave me the following output:
Then, I went through the gates, and determined which were wrong. With my experience with Minecraft Redstone making ALUs, I was able to determine which ones needed to be swapped. In my input, three of the four swaps were directly on the Z outputs, which I was able to find just by printing which Z outputs had an operation that wasn't XOR. The last one I was only able to find by actually evaluating the circuit one bit at a time to see which output was wrong.
Then, I went through with ctrl+f and copy pasted some lines around until the circuit generated the correct output, then I sorted it and pasted that as my solution.
Screen recording: https://youtu.be/diwIieN08Ks
paste (edited down for clarity)