I have read: Tips for golfing in Python
I would like to golf this code further. Any more tips?
x,y,q,w=[int(i) for i in raw_input().split()] while 1: a=int(input()) s=d="" if q>x: s="W" q-=1 elif q<x: s="E" q+=1 if w>y: d="N" w-=1 elif w<y: d="S" w+=1 print d+s
The program: You move on a map which is 40 wide by 18 high. Thor is initially placed on a random spot on the map and must reach the light of power as quickly as possible. You need to have the shortest code possible.
During each turn, you must specify in which direction to move, from one of the following:
N (North) NE (North-East) E (East) SE (South-East) S (South) SW (South-West) W (West) NW (North-West)
YOU WIN WHEN THOR REACHES THE LIGHT OF POWER.
YOU LOSE: if Thor moves off the map. if Thor doesn't have enough energy left to reach the light of power.
EXAMPLE: THOR STARTS ON THE MAP ON THE SQUARE (3, 6). THE LIGHT OF POWER IS ON SQUARE (3, 8).
TURN 1 THOR MOVES SOUTHWARDS. NEW POSITION = (3, 7). THOR HAS ENOUGH ENERGY LEFT FOR 10 MOVES
TURN 2 THOR MOVES SOUTHWARDS. NEW POSITION = (3, 8). THOR HAS ENOUGH ENERGY LEFT FOR 9 MOVES
The program must first read the initialization data from standard input. Then, within an infinite loop, read the data from the standard input related to Thor's current state and provide to the standard output Thor's movement instructions.
INITIALIZATION INPUT: Line 1: 4 integers indicate the position of the light of power. 2 indicate Thor’s starting position.
INPUT FOR ONE GAME TURN: Line 1: The level of Thor’s remaining energy. This represents the number of moves he can still make.
OUTPUT FOR ONE GAME TURN: A single line providing the move to be made: N NE E SE S SW W or NW
Edit : it's a code golf on codingame.com