Skip to content

Instantly share code, notes, and snippets.

@mmas
Created July 5, 2017 00:02
Show Gist options
  • Save mmas/572461f76fc3723314a2454937f95b2a to your computer and use it in GitHub Desktop.
Save mmas/572461f76fc3723314a2454937f95b2a to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import sys
last_k = None
max_v = 0
for line in sys.stdin:
k, v = line.strip().split('\t')
v = int(v)
if last_k == k:
max_v = max(max_v, v)
else:
if last_k:
print '%s\t%s' % (last_k, max_v)
last_k = k
max_v = v
if last_k == k:
print '%s\t%s' % (last_k, max_v)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment