You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
811 B
31 lines
811 B
#!/usr/bin/env python3
|
|
|
|
import sys
|
|
import networkx as nx
|
|
|
|
|
|
if __name__ == '__main__':
|
|
pcs = [line.strip('\n').split('-') for line in open(sys.argv[1])]
|
|
|
|
d = {}
|
|
t = set([])
|
|
for con in pcs:
|
|
if con[0] in d:
|
|
d[con[0]].append(con[1])
|
|
else: d[con[0]] = [con[1]]
|
|
if con[0].startswith('t'): t.add(con[0])
|
|
if con[1].startswith('t'): t.add(con[1])
|
|
G = nx.Graph(d)
|
|
|
|
res1 = 0
|
|
for clique in nx.enumerate_all_cliques(G):
|
|
if len(clique) == 3 and len(set(clique).intersection(t)) > 0: res1 += 1
|
|
if len(clique) == 4: break
|
|
res2 = ','.join(sorted(sorted([c for c in nx.find_cliques(G)],key=len, reverse=True)[0]))
|
|
|
|
# challenge 1
|
|
print(f"challenge 1:\n{res1}\n")
|
|
|
|
# challenge 2
|
|
print(f"challenge 2:\n{res2}")
|
|
|
|
|