Created
March 17, 2016 10:11
-
-
Save MajorTal/df51a71044774ab27348 to your computer and use it in GitHub Desktop.
Edits
This file contains hidden or 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
0.41 KB | |
def edits1(word): | |
splits = [(word[:i], word[i:]) for i in range(len(word) + 1)] | |
deletes = [a + b[1:] for a, b in splits if b] | |
transposes = [a + b[1] + b[0] + b[2:] for a, b in splits if len(b)>1] | |
replaces = [a + c + b[1:] for a, b in splits for c in alphabet if b] | |
inserts = [a + c + b for a, b in splits for c in alphabet] | |
return set(deletes + transposes + replaces + inserts) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment