mirror of
https://github.com/peter-tanner/advent-of-code-2020.git
synced 2024-11-30 10:50:17 +08:00
22 lines
512 B
Python
22 lines
512 B
Python
|
|
ACC = 0
|
|
INDEX = 0
|
|
|
|
indices = []
|
|
|
|
lines = [ [y[0],int(y[1])] for x in open('input').read().splitlines() if (y := x.split(' ')) ]
|
|
|
|
while INDEX not in indices:
|
|
instruction = lines[INDEX][0]
|
|
arg0 = lines[INDEX][1]
|
|
print(instruction + ' ' + str(arg0) + ' ' + str(ACC) + ' ' + str(INDEX) )
|
|
if instruction == 'nop':
|
|
True
|
|
elif instruction == 'acc':
|
|
ACC += arg0
|
|
elif instruction == 'jmp':
|
|
INDEX += arg0 - 1
|
|
indices.append(INDEX)
|
|
INDEX += 1
|
|
|
|
|