Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #quarkie 26.02
- import math
- LX, LY, TX, TY = [int(i) for i in input().split()]
- dists = [] #distances from neighbor positions
- directions = ['N', 'NE', 'E', 'SE', 'S', 'SW', 'W', 'NW']
- changes = [[0,-1],[+1,-1], [+1,0], [+1,1], [0,1], [-1,1], [-1,0], [-1,-1], ]
- dist = lambda LX, LY, TX, TY : math.sqrt(pow(abs(LX-TX),2) + pow(abs(LY-TY),2) )
- def dists_fill(LX, LY, TX, TY):
- del dists[:]
- for i in changes:
- dists.append(dist(LX, LY, TX+i[0], TY+i[1])) # create a distances on directions
- return dists
- while 1:
- dir = directions[ dists_fill(LX,LY,TX,TY).index( min( dists )) ]
- print(dir)
- TX += changes[directions.index(dir)][0]
- TY += changes[directions.index(dir)][1]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement