题目描述
密码要求:
1.长度超过8位
2.包括大小写字母.数字.其它符号,以上四种至少三种
3.不能有相同长度超2的子串重复
说明:长度超过2的子串
输入描述:
一组或多组长度超过2的子符串。每组占一行
输出描述:
如果符合要求输出:OK,否则输出NG
示例1
输入
021Abc9000
021Abc9Abc1
021ABC9000
021$bc9000
输出
OK
NG
NG
OK
def check1(string):
if len(string)<=8:
return False
else:
return True
def check2(string):
uppernum=0
lowernum=0
digitnum=0
othernum=0
for each in string:
if 'A'<=each<='Z':#每种计数1
uppernum=1
elif 'a'<=each <='z':
lowernum=1
elif '0'<=each<='9':
digitnum=1
else:
othernum=1
if (uppernum+lowernum+digitnum+othernum)>=3:#至少有三种
return True
else:
return False
def check3(string):
for i in range(len(string)-3):#不能有相同长度超2的子串重复,相同长度为3的判断
if string.count(string[i:i+3])>1:#每截取3个子串判断在字符串中的数目
return False
return True
while True:
try:
string=input()
if check1(string) and check2(string) and check3(string):
print('OK')
else:
print('NG')
except:
break