comparison python/safe.py @ 9:0d1670ab37df

towards useful output
author Henry S. Thompson <ht@inf.ed.ac.uk>
date Wed, 26 May 2021 13:52:53 -0400
parents fcef94b6324c
children 73bb35b96624
comparison
equal deleted inserted replaced
8:fcef94b6324c 9:0d1670ab37df
82 dx=p1[0]-p2[0] 82 dx=p1[0]-p2[0]
83 dz=p1[1]-p2[1] 83 dz=p1[1]-p2[1]
84 dy=p1[2]-p2[2] 84 dy=p1[2]-p2[2]
85 return math.sqrt((dx*dx)+(dy*dy)+(dz*dz)) 85 return math.sqrt((dx*dx)+(dy*dy)+(dz*dz))
86 86
87 def unsafe(p): 87 def safety(p):
88 ka=[(a[0],a[2]) for a in A.points if d(a,p)<=n] 88 ka=[(a[0],a[2]) for a in A.points if d(a,p)<=n]
89 return [(k,A.columns[k],L.columns[k]) for k in ka if k in L.columns] 89 return [(k,A.columns[k],L.columns[k]) for k in ka if k in L.columns]
90 90
91 readHeaders(sys.modules['__main__'],sys.stdin,False) 91 readHeaders(sys.modules['__main__'],sys.stdin,False)
92 for l in sys.stdin: 92 for l in sys.stdin:
93 c=eval(l) 93 c=eval(l)
94 s=[(p,unsafe(p)) for p in c] 94 ss=[]
95 95 hits={}
96 print(s if s else 'No air',c) 96 misses=[]
97 97 for p in c:
98 98 s=safety(p)
99 if s:
100 pass
101 else:
102 misses.append(p)
103 print(c)
104 print(' %s nearby landing zones'%(
105 (lambda nm,nc:'No' if nm==nc else nc-nm)(len(misses),len(c))))