How could I reduce the length of this code? I need to reduce the length of this code in Python 3 as much as possible (even if it will be less readable):

a,b,x,y=[int(i) for i in input().split()]
while 1: 
 r=''
 if y&lt;b:r='S';y+=1
 if y&gt;b:r='N';y-=1 
 if x&lt;a:r+='E';x+=1
 if x&gt;a:r+='W';x-=1
 print(r)


It's a map: you are on (x,y) and you need to go to (a,b). S for South, N for North, NE for North East and so on. After each turn I must tell where to go using print.

Update: This is what I've got now, but is there any way to shorten it further?

a,b,x,y=map(int,input().split())
while 1:c,d=(y&gt;b)-(y&lt;b),(x&gt;a)-(x&lt;a);print((' NS'[c]+' WE'[d]).strip());y-=c;x-=d
Python 3, 107

a,b,x,y=map(int,input().split())
A=abs(a-x);B=abs(b-y)
while 1:print('SN'[b&gt;y][:B]+'WE'[a&gt;x][:A]);A-=1;B-=1


A different strategy to generate the directions, tracking each coordinate's absolute displacement to the goal rather than the actual location.

For the horizontal direction, finds the absolute displacement A=abs(a-x) and direction character 'WE'[a&gt;x]. Simulates going towards the goal by decrementing A and printing the direction character as long as we haven't already reached the goal coordinate (A&gt;0). Does the same for vertical.