Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
regex and any(), but I feel like the description and verification conditions are subjective solution in Clear category for Acceptable Password VI by lucas.stonedrake
# using regex
import re
def is_acceptable_password(password: str) -> bool:
if 'password' in password.lower(): return False
if len(password) == 10: return True #all passwords of length 10 are True??
# True if password is between 6 and 10 long exclusive, contains at least one digit, isn't all digits, and contains at least three alphanumeric characters
if 6 < len(password) < 10 and re.search('[0-9]', password) and not password.isdigit() and len(set(filter(str.isalnum, password))) > 2: return True
# must have at least three alphanumeric characters
if len(password) > 10: return len(set(filter(str.isalnum, password))) > 2
return False
#tiny variation without needing regex
def is_acceptable_password(password: str) -> bool:
if 'password' in password.lower(): return False
if len(password) == 10: return True #all passwords of length 10 are True??
# True if password is between 6 and 10 long exclusive, contains at least one digit, isn't all digits, and contains at least three alphanumeric characters
if 6 < len(password) < 10 and any(char.isdigit() for char in password) and not password.isdigit() and len(set(filter(str.isalnum, password))) > 2: return True
# must have at least three alphanumeric characters
if len(password) > 10: return len(set(filter(str.isalnum, password))) > 2
return False
Nov. 9, 2020