Untitled
with open("22.txt") as file: d = {'0': 0} for elem in file.readlines(): elem = elem.replace("\t", " ") num, dur, *subs = elem.replace(';', ' ').split() d[num] = max([d[i] for i in subs]) + int(dur) print(max(d.values()))
with open("22.txt") as file: d = {'0': 0} for elem in file.readlines(): elem = elem.replace("\t", " ") num, dur, *subs = elem.replace(';', ' ').split() d[num] = max([d[i] for i in subs]) + int(dur) print(max(d.values()))