题解 | #密码验证合格程序#python3速度快于65%
密码验证合格程序
http://www.nowcoder.com/practice/184edec193864f0985ad2684fbc86841
def check(sub_pswd):
if len(sub_pswd) <=8:
return False
flag =[0,0,0,0]
for i in sub_pswd:
if '0'<= i <='9':
flag[0] = 1
elif 'A'<= i <='Z':
flag[1] = 1
elif 'a'<= i <='z':
flag[2] = 1
else:
flag[3] = 1
if sum(flag) >=3 :
for i in range(len(sub_pswd)-3):
if sub_pswd.count(sub_pswd[i:i+3]) >=2:
return False
return True
else:
return False
while True:
try:
pswd = input()
print('OK' if check(pswd) else 'NG')
except:
break