This commit is contained in:
2020-12-08 09:24:37 +01:00
parent c0d32dfdbd
commit 23c9844a9f
2 changed files with 680 additions and 0 deletions

39
day8/day8.py Normal file
View File

@@ -0,0 +1,39 @@
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()