This commit is contained in:
Sijmen 2018-12-07 08:07:03 +01:00
parent 7af9677207
commit 829128a5be

27
Day7/Day7.py Normal file
View file

@ -0,0 +1,27 @@
import fileinput
from collections import defaultdict
def work_seconds(node):
return ord(node) - ord('A') + 60
graph = defaultdict(set)
for line in fileinput.input():
a = line[5]
b = line[36]
graph[b].add(a)
graph[a]
order = []
to_consider = sorted(graph.keys())
while to_consider:
for i, node in enumerate(to_consider):
parents = graph[node]
if any(parent in to_consider for parent in parents):
continue
order.append(node)
del to_consider[i]
break
print("".join(order))