You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
677 B
Python
38 lines
677 B
Python
4 years ago
|
import time
|
||
|
|
||
|
tag8 = open('input', 'r')
|
||
|
|
||
|
tag8 = [x.strip() for x in tag8]
|
||
|
|
||
|
print(tag8)
|
||
|
|
||
|
acc = 0
|
||
|
zeiger = 0
|
||
|
|
||
|
besucht = list()
|
||
|
|
||
|
print('=' * 10, ' start loop', '=' * 10)
|
||
|
while True:
|
||
|
if zeiger in besucht:
|
||
|
break
|
||
|
|
||
|
zeile = tag8[zeiger]
|
||
|
besucht.append(zeiger)
|
||
|
|
||
|
instruction = zeile[0:3]
|
||
|
number = int(zeile[4:])
|
||
|
if instruction == 'jmp':
|
||
|
zeiger += number
|
||
|
else:
|
||
|
zeiger += 1
|
||
|
if instruction == 'acc':
|
||
|
acc += number
|
||
|
|
||
|
print(zeile, '\tacc:', acc, '\tzeiger:', zeiger, '\tbesucht:', besucht)
|
||
|
print()
|
||
|
time.sleep(0.3)
|
||
|
|
||
|
print('=' * 10, ' end loop', '=' * 10)
|
||
|
|
||
|
print('acc:', acc, '\tzeiger:', zeiger, '\tbesucht:', besucht)
|