题解 | #密码验证合格程序#
密码验证合格程序
https://www.nowcoder.com/practice/184edec193864f0985ad2684fbc86841
# 哇哈哈,我真是个小天才!!! import sys import re lists = [] for line in sys.stdin: line = line.rstrip("\n") lists.append(line) def f(x): zt = "" count1 = 0 count=0 shuzi=re.findall("[0-9]+", x) small_zimu=re.findall("[a-z]+", x) big_zimu=re.findall("[A-Z]+", x) for i in range(len(x) - 3): num = x.count(x[i : i + 3]) if num > 1: zt = "NG" break else: pass if len(shuzi) > 0: for t in range(len(shuzi)): count=count+len(shuzi[t]) count1 += 1 if len(small_zimu) > 0: for t in range(len(small_zimu)): count=count+len(small_zimu[t]) count1 += 1 if len(big_zimu) > 0: for t in range(len(big_zimu)): count=count+len(big_zimu[t]) count1 += 1 if re.findall(r"\s", x) or re.findall(r"\n", x) or count1 < 3 and count==len(x) or len(x) < 9: zt = "NG" return zt lists = list(map(f, lists)) lists=list(map(lambda x:"OK"if x=="" else x,lists)) for i in lists: print(i)