Created
March 24, 2011 23:25
-
-
Save ThawanFidelis/886094 to your computer and use it in GitHub Desktop.
função para encontrar anagrama de uma palavra
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
def anagrams(s): | |
# Return the list of anagrams for s | |
if s == "": | |
return [s] | |
else: | |
ans = [] | |
for w in anagrams(s[1:]): | |
for pos in range(len(w)+1): | |
ans.append(w[:pos]+s[0]+w[pos:]) | |
return ans |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment