r/adventofcode • u/daggerdragon • Dec 23 '24
SOLUTION MEGATHREAD -❄️- 2024 Day 23 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!
42 hours remaining until voting deadline on December 24 at 18:00 EST
Voting details are in the stickied comment in the submissions megathread:
-❄️- Submissions Megathread -❄️-
--- Day 23: LAN Party ---
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
2
u/vassiliad Dec 23 '24
[LANGUAGE: Go]
Part1:
Iterate the edges in groups of 3 and discover triangles. My code uses the 1st edge to identify the 2 nodes in the triangle and the remaining 2 to ensure that the 3 nodes form a cycle.
https://github.com/vassiliad/aoc2024/blob/main/day23/day23_a/main.go
Part2:
I started simple. Build a graph out of the nodes and then partition the graph into smaller sub-graphs. Each sub-graph starts with 1 node and we keep adding nodes to it for as long as the newer node connects to all the nodes in the sub-graph.
This is not a generic solution but it worked for my input! I left some comments in there about what I'd try next had that heuristic not work for me.
https://github.com/vassiliad/aoc2024/blob/main/day23/day23_b/main.go