Created
December 24, 2013 01:57
-
-
Save hmkz/8107759 to your computer and use it in GitHub Desktop.
標準入力から重複した行を計算して出力する。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import sys | |
tmp = {} | |
for line in sys.stdin: | |
line = line.strip() | |
if line not in tmp: | |
tmp[line] = 0 | |
else: | |
tmp[line] += 1 | |
for k,v in sorted(tmp.items(), key=lambda x:x[1]): | |
print k, v |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment