Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- vect = 0
- x = 0
- y = 0
- f = open('instructions.txt', "r")
- def move(step:int):
- global x,y
- if vect == 0:
- x += step
- if vect == 90:
- y += step
- if vect == 180:
- x -= step
- if vect == 270:
- y -= step
- def turn(where):
- global vect
- if where == 'left':
- vect -= 90
- else:
- vect += 90
- if vect == -90:
- vect == 270
- if vect == 420:
- vect == 90
- if vect == 360:
- vect == 0
- for line in f:
- spl = line.lower().split()
- if len(spl) > 1:
- move(int(spl[1]))
- elif (spl[0] == 'left') or (spl[0] == 'right'):
- turn(line)
- elif spl[0] == 'stop':
- print()
- if (x,y) == (0,0):
- print(0)
- if (x,y) == (1,0):
- print(1)
- if (x,y) == (2,0):
- print(2)
- if (x,y) == (3,0):
- print(3)
- if (x,y) == (0,1):
- print(4)
- if (x,y) == (0,-1):
- print(5)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement