23 lines
536 B
Python
Executable File
23 lines
536 B
Python
Executable File
#!/bin/python
|
|
|
|
with open("input", 'r') as input:
|
|
code = [line.strip() for line in input.readlines()]
|
|
visited = [False for _ in range(len(code) + 1)]
|
|
acc = 0
|
|
pointer = 0;
|
|
|
|
while not visited[pointer]:
|
|
instr = code[pointer].split(" ")
|
|
|
|
visited[pointer] = True
|
|
|
|
if instr[0] == "acc":
|
|
acc += int(instr[1])
|
|
pointer += 1
|
|
elif instr[0] == "nop":
|
|
pointer += 1
|
|
elif instr[0] == "jmp":
|
|
pointer += int(instr[1])
|
|
|
|
print(acc)
|