""" day 9 part 1 """ import fileinput allocs = [] for line in fileinput.input(): for i, v in enumerate(line.strip()): if i % 2 == 0: allocs += [i//2]*int(v) else: allocs += [None]*int(v) print(allocs) for i in range(len(allocs)): if i >= len(allocs): break if allocs[i] is None: while allocs[-1] is None: allocs.pop() if i < len(allocs) - 1: allocs[i] = allocs.pop() print(allocs) chk = 0 for i, val in enumerate(allocs): chk += i*val print(chk)