6 directions=["E", "S", "W", "N"]
8 def do_move(direction, amount):
11 if direction in ["E", "W"]:
15 elif direction in ["N", "S"]:
20 def turn(amount,multiplier):
25 for a,dir2 in enumerate(directions):
26 if dir2 == ship_direction:
30 print("Loc: {}".format(dir_pos))
32 dir_pos+=int((int(amount) / 90) * multiplier)
33 dir_pos=(dir_pos % len(directions))
34 print("New loc: {}".format(dir_pos))
35 print("Started in direction {}, changing to direction {}, after getting told to go {}".format(ship_direction, directions[dir_pos], (int(amount) * multiplier)))
36 ship_direction=directions[dir_pos]
38 def turn_right(amount):
41 def turn_left(amount):
44 for line in open("input.txt", "r"):
49 if command in [ "N", "S", "E", "W" ]:
50 do_move(command, amount)
56 do_move(ship_direction, amount)
58 print("Moved to {}, {} - MD: {}".format(ship_horz,ship_vert,(abs(ship_horz)+abs(ship_vert))))