Last active
August 29, 2015 14:07
-
-
Save elpargo/cc487d07deb7d7d16337 to your computer and use it in GitHub Desktop.
Puedo hacer con Python una aplicación que me genere 6 grupos de 5 caracteres alfanuméricos y que no repita?.
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 string | |
import random | |
current = set(string.digits+string.letters) | |
for i in range(6): | |
sample = random.sample(current,5) | |
current = current - set(sample) | |
print sample |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
desafortunadamente python no tiene un metodo group para agrupar elementos por tamano N http://stackoverflow.com/questions/4998427/how-to-group-elements-in-python-by-n-elements
pero una solucion podria ser:
python es mejor para codigo imperativo, cuando tratas de programar mas funcional es limitado.....