Created
December 6, 2019 10:42
-
-
Save bclavie/a170c703ab981385d756a3ce16ea2ea7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Please use the following encoding: utf-8, thanks! | |
import networkx as nx | |
''' Part 1''' | |
graph = nx.read_edgelist('./data/day6_input.txt', delimiter=')', create_using=nx.DiGraph) | |
orbit_count = sum(len(nx.ancestors(G=graph, source=node)) for node in graph.nodes) | |
print(orbit_count) | |
''' Part 2 ''' | |
undir_graph = nx.read_edgelist('./data/day6_input.txt', delimiter=')', create_using=nx.Graph) | |
shortest = len(nx.shortest_path(undir_graph, source="YOU", target="SAN")) - 3 | |
print(shortest) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment