my solutions for advent of code 2022
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
591 B

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)