Skip to content

Instantly share code, notes, and snippets.

@machinaut
Forked from zmagg/word_games.py
Created August 15, 2013 00:23
Show Gist options
  • Save machinaut/6237156 to your computer and use it in GitHub Desktop.
Save machinaut/6237156 to your computer and use it in GitHub Desktop.
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