word-diff

How can I optimize this Python code to generate all words with word-distance 1?

How can I optimize this Python code to generate all words with word-distance 1? Question: Profiling shows this is the slowest segment of my code for a little word game I wrote: def distance(word1, word2): difference = 0 for i in range(len(word1)): if word1[i] != word2[i]: difference += 1 return difference def getchildren(word, wordlist): return …

Total answers: 12