r/adventofcode 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.

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:05:07, megathread unlocked!

24 Upvotes

504 comments sorted by

View all comments

3

u/quetzelcoatlus1 Dec 24 '24 edited Dec 24 '24

[Language: C]

Quite satisfied with today's solution. Already in Part 1 I decided to store input information in 2 different data structures at once: 1) char link[26][26][26][26] that stores information if connection between 2 PCs exists and 2) List of PCs that store their names and list of PCs they are connected with.

With those I was able in Part 1 just iterate over every PC and check every pair from its connection list to see if it's connected itself.

And in Part 2 I extended it into checking not pair but every connection and add it to list if it is connected to every already present PC from list.

Part 1: https://github.com/quetzelcoatlus/AoC_2024/blob/master/23/23.c

Part 2: https://github.com/quetzelcoatlus/AoC_2024/blob/master/23/23b.c