def check(): if cycle in [20, 60, 100, 140, 180, 220]: tempa = cycle * register checkpoints.append(tempa) with open('input10.txt','r') as f: inp = f.read().splitlines(keepends=False) cycle = 0 line = 0 register = 1 checkpoints = [] _sum = 0 while cycle < 220: ins = inp[line] line += 1 if 'noop' in ins: cycle += 1 check() elif 'addx' in ins: cycle += 1 check() cycle += 1 check() tempa, tempb = ins.split(' ') register += int(tempb) for i in checkpoints: _sum += i print(_sum)