Skip to content

Instantly share code, notes, and snippets.

@yuheiomori
Created May 12, 2012 06:43
Show Gist options
  • Save yuheiomori/2664672 to your computer and use it in GitHub Desktop.
Save yuheiomori/2664672 to your computer and use it in GitHub Desktop.
CodeEval Longest Lines
import sys
def longest_lines(l, n):
l.sort(key=lambda x: len(x) * -1)
return l[:n]
if __name__ == '__main__':
test_cases = open(sys.argv[1], 'r')
lines = [i.rstrip() for i in test_cases]
print '\n'.join(longest_lines(lines[1:], int(lines[0])))
test_cases.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment