Skip to content

Commit

Permalink
2024 - Day 23A: LAN Party
Browse files Browse the repository at this point in the history
  • Loading branch information
supertom01 committed Dec 24, 2024
1 parent d44a5a1 commit 2eefc54
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions 2024/day23.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from day_base import Day

class Day23(Day):

def __init__(self):
super().__init__(2024, 23, 'LAN Party', debug=False, expected_a=7)

def part_a(self):
# Find to which computer each other computer is connected
graph = dict()
for line in self.input:
c1, c2 = line.split('-')

if c1 not in graph:
graph[c1] = []
graph[c1].append(c2)

if c2 not in graph:
graph[c2] = []
graph[c2].append(c1)

# Find all inter-connected computers
inter_connected_computers = set()
for c1, computers in graph.items():
for c2 in computers:
for c3 in graph[c2]:
if c3 in computers and any(c.startswith('t') for c in [c1, c2, c3]):
inter_connected_computers.add(frozenset([c1, c2, c3]))

return len(inter_connected_computers)

if __name__ == '__main__':
(Day23()).run()

0 comments on commit 2eefc54

Please sign in to comment.