描述
密码要求:
1.长度超过8位
2.包括大小写字母.数字.其它符号,以上四种至少三种
3.不能有长度大于2的包含公共元素的子串重复 (注:其他符号不含空格或换行)
数据范围:输入的字符串长度满足 1 \le n \le 100 \1≤n≤100
输入描述:
一组字符串。
输出描述:
如果符合要求输出:OK,否则输出NG
输入:
021Abc9000
021Abc9Abc1
021ABC9000
021$bc9000
输出:
OK
NG
NG
OK
import sys
def lianxi(shuju1):
count = [0, 0, 0, 0]
if len(shuju1) <= 8:
return 'NG'
for i in shuju1:
if count.count(1) >= 3:
return lianxi2(shuju1)
continue
if i.isupper():
count[0] = 1
continue
if i.islower():
count[1] = 1
continue
if i.isdigit():
count[2] = 1
continue
if i != ' ':
count[3] = 1
continue
num = count.count(1)
print(count.count(1))
if count.count(1) >= 3:
return lianxi2(shuju1)
else:
return 'NG'
def lianxi2(shuju1):
# print(shuju1)
temp = ''.join(shuju1)
# print(temp)
for k in range(0, len(shuju1)):
if k == len(shuju1) - 1:
return 'OK'
for j in range(k + 3, len(shuju1)):
# print(shuju1[k: j])
temp2 = ''.join(shuju1[k: j])
if temp.count(temp2) > 1:
return 'NG'
else:
k = k + 1
if __name__ == '__main__':
shuju1 = []
while True:
line = sys.stdin.readline().strip()
if line == '':
break
shuju1.append(line)
for i in range(0, len(shuju1)):
print(lianxi(shuju1[i]))