Created
May 8, 2012 00:08
-
-
Save yuheiomori/2631567 to your computer and use it in GitHub Desktop.
CodeEval Uniq Elements
This file contains hidden or 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
from itertools import ifilterfalse | |
import sys | |
def unique(iterable): | |
seen = set() | |
seen_add = seen.add | |
for element in ifilterfalse(seen.__contains__, iterable): | |
seen_add(element) | |
yield element | |
if __name__ == '__main__': | |
test_cases = open(sys.argv[1], 'r') | |
for line in test_cases: | |
print ','.join(unique(line.rstrip().split(','))) | |
test_cases.close() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment