-
-
Save manlon/965e4f5d0b2aec6a730917d075e5a455 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
def inputs(): | |
for line in open("./input4.txt"): | |
yield line.split() | |
def sort_string(s): | |
l = list(s) | |
l.sort() | |
return "".join(l) | |
def has_dupes(words): | |
s = set() | |
for w in words: | |
if w in s: | |
return True | |
s.add(w) | |
return False | |
print len(list(p for p in inputs() if not has_dupes(p))) | |
print len(list(p for p in inputs() if not has_dupes(sort_string(w) for w in p))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment