题解 | #密码验证合格程序#
密码验证合格程序
http://www.nowcoder.com/practice/184edec193864f0985ad2684fbc86841
蠢办法,条件一个一个过,不过在判断重复子串的部分,时间复杂度可以修改的更好
while True:
try:
a=input()
up=0
low=0
sz=0
fh=0
import string
punc=string.punctuation
flag='OK'
if len(a)<=8:
flag='NG'
print(flag)
else:
for i in a:
if i.isdigit():
sz=1
elif i.islower():
low=1
elif i.isupper():
up=1
elif i in punc:
fh=1
l=[up,low,sz,fh]
if l.count(1)<3:
flag='NG'
print(flag)
else:
for i in range(len(a)):
maxlength=3
b=a[i+maxlength:]
if a[i:i+maxlength] in b:
flag='NG'
print(flag)
except:
break