Skip to content

Instantly share code, notes, and snippets.

@ntlk
Last active December 25, 2015 09:29
Show Gist options
  • Save ntlk/6954880 to your computer and use it in GitHub Desktop.
Save ntlk/6954880 to your computer and use it in GitHub Desktop.
actually unique uniq implemented in python
import sys
import argparse
import collections
parser = argparse.ArgumentParser()
parser.add_argument('-c', action='store_const', const=True, required=False)
args = parser.parse_args()
lines = sys.stdin.readlines()
counter = collections.Counter(lines)
for line in set(lines):
if args.c == True:
line = str(counter[line]) + " " + line
sys.stdout.write(line)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment