Skip to content

Instantly share code, notes, and snippets.

@korjavin
Last active February 4, 2016 17:15
Show Gist options
  • Save korjavin/8f51d62c4021d4d3b77d to your computer and use it in GitHub Desktop.
Save korjavin/8f51d62c4021d4d3b77d to your computer and use it in GitHub Desktop.
#!env python
import sys
(lastKey,minDist,minVals)=(None,0,'')
for line in sys.stdin:
arr = line.strip().split("\t")
v=arr[0]
d=arr[1]
vals=arr[2].replace('{','').replace('}','')
if lastKey and lastKey != v:
x = "%.3f" % (0.2*0.1+0.9*minDist)
print (lastKey + '\t' + x + '\t{' + minVals + '}')
(lastKey,minDist,minVals)=(v,0,'')
else:
lastKey =v
if vals!='':
minVals=vals
else:
minDist+=float(d)
if lastKey :
x = "%.3f" % (0.2*0.1+0.9*minDist)
print (lastKey + '\t' + x + '\t{' + minVals + '}')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment