Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- import math
- def MoveCalc(Official_x, Official_y):#I know... it's lame but I don't care ;)
- print(Official_x, file=sys.stderr)
- print(Official_y, file=sys.stderr)
- global Movement
- global Lame
- Lame = Official_y
- list_Total = [Official_x, Lame]
- Pos_List = []
- for i in range(len(list_Total)):
- Pos_List.append(list_Total[i] * list_Total[i])
- if Pos_List[0] != Pos_List[1]:
- MaxValue = max(Pos_List)
- for i in range(len(Pos_List)):
- if MaxValue == Pos_List[i]:
- ID = i
- break
- if ID == 0:
- if Official_x > 0:
- Movement = "W"
- Official_x = Official_x - 1
- Lame = Official_x
- return Lame
- elif Official_x < 0:
- Movement = "E"
- Official_x = Official_x + 1
- print(Official_x)
- return Official_x
- if ID == 1:
- if Lame > 0:
- Movement = "N"
- Lame = Lame - 1
- return Lame
- elif Lame < 0:
- Movement = "S"
- Official_y = Official_y + 1
- print(Official_y)
- return Official_y
- else:
- if Official_y > 0 and Official_x > 0:
- Movement = "NW"
- elif Official_y < 0 and Official_x < 0:
- Movement = "SE"
- elif Official_y < 0 and Official_x > 0:
- Movement = "SW"
- elif Official_y > 0 and Official_x < 0:
- Movement = "NE"
- # 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 = 5
- light_y = 3
- initial_tx = 23
- initial_ty = 34
- Official_x = initial_tx - light_x
- Official_y = initial_ty - light_y
- # game loop
- print(light_x, light_y, initial_tx, initial_ty, file=sys.stderr)
- while True:
- # Write an action using print
- # To debug: print("Debug messages...", file=sys.stderr)
- # A single line providing the move to be made: N NE E SE S SW W or NW
- MoveCalc(Official_x, Official_y)
- Official_y = Lame
- print(Lame)
- print(Official_x, Official_y, file=sys.stderr)
- print(Movement)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement