Last active
December 18, 2015 21:19
-
-
Save IuryAlves/5846476 to your computer and use it in GitHub Desktop.
This file contains 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
import urllib.request | |
import random | |
palavras = urllib.request.urlopen( | |
'http://www.puzzlers.org/pub/wordlists/unixdict.txt' | |
).read().decode('iso8859').lower().split() | |
def escolha(): | |
while True: | |
anagramas = [] | |
palavra = random.choice(palavras).lower() | |
anagramas.append(palavra) | |
for p in palavras: | |
if sorted(p) == sorted(palavra): | |
if p != palavra: | |
anagramas.append(p) | |
if p == palavras[-1]: | |
if len(anagramas) > 1 : | |
return anagramas | |
else: | |
anagramas = [] | |
anagrama = escolha() | |
print(anagrama) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment