Skip to content

Instantly share code, notes, and snippets.

@ThawanFidelis
Created March 24, 2011 23:25
Show Gist options
  • Save ThawanFidelis/886094 to your computer and use it in GitHub Desktop.
Save ThawanFidelis/886094 to your computer and use it in GitHub Desktop.
função para encontrar anagrama de uma palavra
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