My task is to generate a random string with following parameters:
- At least one Uppercase
- At least one lower
- At least one digit
- No repeated chars/digits allowed ( e.g. aa not allowed, aba is allowed, Aa is allowed)
I'm able to generate a random string with 1,2,3 parameters but parameter 4 logic is missing.
inputChars = [('a'..'z'), ('A'..'Z'),(0..9)].map(&:to_a).flatten
string = (0...16).map { inputChars[rand(inputChars.length)] }.join
Aucun commentaire:
Enregistrer un commentaire