-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paththor.py
47 lines (35 loc) · 1.33 KB
/
thor.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import sys
import math
# Auto-generated code below aims at helping you parse
# the standard input according to the problem statement.
# ---
# Hint: You can use the debug stream to print initialTX and initialTY, if Thor seems not follow your orders.
# light_x: the X position of the light of power
# light_y: the Y position of the light of power
# initial_tx: Thor's starting X position
# initial_ty: Thor's starting Y position
light_x, light_y, initial_tx, initial_ty = [int(i) for i in raw_input().split()]
# game loop
while True:
remaining_turns = int(raw_input()) # The remaining amount of turns Thor can move. Do not remove this line.
# Write an action using print
# To debug: print >> sys.stderr, "Debug messages..."
# A single line providing the move to be made: N NE E SE S SW W or NW
diff_x = light_x - initial_tx
diff_y = light_y - initial_ty
ans = ''
while diff_x !=0 or diff_y !=0:
if diff_y > 0:
ans = ans + 'S'
diff_y = diff_y - 1
if diff_y < 0:
ans = ans + 'N'
diff_y = diff_y + 1
if diff_x > 0:
ans = ans + 'E'
diff_x = diff_x - 1
if diff_x < 0:
ans = ans + 'W'
diff_x = diff_x + 1
print ans
ans = ''