"solve" 25a
This commit is contained in:
parent
c2601d433a
commit
a76baabd68
|
@ -0,0 +1,13 @@
|
|||
jqt: rhn xhk
|
||||
rsh: frs pzl lsr
|
||||
xhk: hfx
|
||||
cmg: qnr nvd lhk
|
||||
rhn: xhk bvb hfx
|
||||
bvb: xhk hfx
|
||||
pzl: lsr nvd
|
||||
qnr: nvd
|
||||
ntq: jqt hfx bvb xhk
|
||||
nvd: lhk
|
||||
lsr: lhk
|
||||
rzs: qnr cmg lsr rsh
|
||||
frs: qnr lhk lsr
|
|
@ -0,0 +1,17 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import networkx as nx
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
from useful import *
|
||||
|
||||
g = nx.Graph()
|
||||
for line in lines(open(0)):
|
||||
ic(line)
|
||||
l, r = line.split(': ')
|
||||
for rr in r.split():
|
||||
g.add_edge(l, rr)
|
||||
print(np.prod([len(l) for l in nx.connected_components(g)]))
|
||||
|
||||
#nx.draw(g, with_labels=True)
|
||||
#plt.show()
|
Loading…
Reference in New Issue