Skip to content

Instantly share code, notes, and snippets.

@RyukGremory
Last active April 18, 2018 01:23
Show Gist options
  • Select an option

  • Save RyukGremory/36b3ae28ec0e12d52d6c53863f1b067b to your computer and use it in GitHub Desktop.

Select an option

Save RyukGremory/36b3ae28ec0e12d52d6c53863f1b067b to your computer and use it in GitHub Desktop.
Generador de combinaciones a partir de un set de caracteres.
import hashlib
import itertools
#Que elementos tomara en cuenta para hacer el diccionario
elementos = '20142199PabloAndrésDelaCruzSánchezpdelacruz'
def get_only_chars(string):
return "".join(set(string))
def proceso(n):
listado= list(itertools.combinations_with_replacement(elementos, n))
with open('dictionary_plain.txt','a+') as dictionaryfile:
for e in range(len(listado)-1):
elemento=str("".join(str(x) for x in listado[e])).replace(' ','')
dictionaryfile.write(elemento+'\n')
if __name__=='__main__':
for i in range(1,5): proceso(i)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment