currentfilename = "input.txt"; #currentfilename = "testinput.txt"; #example only f = open(currentfilename, 'r'); myinput = eval(f.read().replace(" ",",")); f.close(); #for i in myinput: # print(i); def NodeAnalysis(License, index): NumberOfChilds = License[index[0]]; index[0] += 1; NumberofEntries = License[index[0]]; index[0] += 1; #print(index, " - this node has ", NumberOfChilds, " and ", NumberofEntries); for child in range(NumberOfChilds): NodeAnalysis(License, index); for entry in range(NumberofEntries): index[1] += License[index[0]]; index[0] += 1; #print("\tcurrent index ", index[0]); i = [0,0]; NodeAnalysis(myinput, i); print("input length\t", len(myinput)); print("final index\t", i[0]); print("part1 answer\t", i[1]);