-
-
Save machinaut/6237156 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
f = open("sowpods.txt", "r") | |
canonized_words = {} | |
word1 = "" | |
word2 = "" | |
max_len = 0 | |
for line in f: | |
if len(line) > max_len: | |
sorted_word = ''.join(sorted(line)) | |
if sorted_word in canonized_words: | |
found_word = canonized_words[sorted_word] | |
word1 = line | |
word2 = found_word | |
max_len = len(word1) | |
else: | |
canonized_words[sorted_word] = line | |
print word1 + ", " + word2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment