Skip to content

Instantly share code, notes, and snippets.

@manlon
Created December 4, 2017 08:33
Show Gist options
  • Save manlon/965e4f5d0b2aec6a730917d075e5a455 to your computer and use it in GitHub Desktop.
Save manlon/965e4f5d0b2aec6a730917d075e5a455 to your computer and use it in GitHub Desktop.
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