40 lines
779 B
Python
40 lines
779 B
Python
def part1():
|
|
file = open("input.txt")
|
|
|
|
instructions = []
|
|
|
|
for line in file:
|
|
args = line.strip().split(" ")
|
|
instructions.append({
|
|
'op': args[0],
|
|
'arg': int(args[1]),
|
|
'visited': False
|
|
})
|
|
|
|
finger = 0
|
|
acc = 0
|
|
|
|
while not instructions[finger]['visited']:
|
|
op = instructions[finger]['op']
|
|
arg = instructions[finger]['arg']
|
|
instructions[finger]['visited'] = True
|
|
|
|
if op == 'nop':
|
|
finger += 1
|
|
continue
|
|
elif op == 'jmp':
|
|
finger += arg
|
|
elif op == 'acc':
|
|
acc += arg
|
|
finger += 1
|
|
|
|
print("Part 1: %d" % acc)
|
|
|
|
def part2():
|
|
print("Part 2: %d")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
part1()
|
|
part2()
|