r/adventofcode • u/topaz2078 (AoC creator) • Dec 12 '17
SOLUTION MEGATHREAD -๐- 2017 Day 12 Solutions -๐-
--- Day 12: Digital Plumber ---
Post your solution as a comment or, for longer solutions, consider linking to your repo (e.g. GitHub/gists/Pastebin/blag or whatever).
Note: The Solution Megathreads are for solutions only. If you have questions, please post your own thread and make sure to flair it with Help.
Need a hint from the Hugely* Handyโ Haversackโก of Helpfulยง Hints^ยค?
This thread will be unlocked when there are a significant number of people on the leaderboard with gold stars for today's puzzle.
edit: Leaderboard capped, thread unlocked!
14
Upvotes
View all comments
1
u/karlanka Dec 12 '17
PYTHON
pipes = {} for line in input_(12).splitlines(): fr, too = line.split(' <-> ') pipes[int(fr)] = [int(x) for x in too.split(', ')] # 1 conn_list = [0] for pipe in conn_list: conn_list.extend([x for x in pipes[pipe] if x not in conn_list]) print(len(conn_list)) # 2 groups = [] for i in range(2000): conn_list = [i] for pipe in conn_list: conn_list.extend([x for x in pipes[pipe] if x not in conn_list]) conn_list.sort() if conn_list not in groups: groups.append(conn_list[:]) print(len(groups))