Mercurial > hg > python
comparison safe.py @ 26:5488b5d3ba10
use indentation and colour to differentiate safe from unsafe landing place
author | Henry Thompson <ht@markup.co.uk> |
---|---|
date | Mon, 31 May 2021 15:01:38 +0100 |
parents | 6df2f6dcc809 |
children | 668d788cac47 |
comparison
equal
deleted
inserted
replaced
25:0bbeb01a7681 | 26:5488b5d3ba10 |
---|---|
117 for k in sorted(hits.keys(),key=lambda k:k[1]): | 117 for k in sorted(hits.keys(),key=lambda k:k[1]): |
118 if k[0] not in done: | 118 if k[0] not in done: |
119 done[k[0]]=1 | 119 done[k[0]]=1 |
120 aa,ll=hits[k] | 120 aa,ll=hits[k] |
121 laa=sorted(list(aa)) | 121 laa=sorted(list(aa)) |
122 print("(%s %s %s)@%0.1f: %s %s"%(k[0][0],laa[0][0],k[0][1],k[1],laa,sorted(list(ll)))) | 122 lll=sorted(list(ll)) |
123 lowAir=laa[0][0] | |
124 highLava=-1 | |
125 j=-1 | |
126 for i,(_,h) in enumerate(lll): | |
127 if h>highLava and h<lowAir: | |
128 highLava=h | |
129 if h+1==lowAir: | |
130 j=i | |
131 break | |
132 if j>-1: | |
133 lava='['+','.join(str(e) if i!=j else \ | |
134 "(%s,%s)"%(e[0],RedFmt%e[1]) for i,e in enumerate(lll))+']' | |
135 lowAir=RedFmt%lowAir | |
136 print("%s(%s %s %s)@%0.1f: %s %s"%(' ' if j>-1 else '', | |
137 k[0][0],lowAir,k[0][1],k[1],laa,lava)) | |
123 else: | 138 else: |
124 print(' No nearby landing zones') | 139 print(' No nearby landing zones') |
125 | 140 |
126 if infile!=sys.stdin: | 141 if infile!=sys.stdin: |
127 infile.close() | 142 infile.close() |