题解 | #密码验证合格程序#
密码验证合格程序
https://www.nowcoder.com/practice/184edec193864f0985ad2684fbc86841
from pickle import TRUE import sys def check_type(str_input): dic={} for j in range(len(str_input)): a=str_input[j] if a.islower(): dic["lower"]=dic.get("lower","")+a elif a.isupper(): dic["upper"]=dic.get("upper","")+a elif a.isdigit(): dic["digit"]=dic.get("digit","")+a else: dic["other"]=dic.get("other","")+a sum=len(dic) if sum>=3: return 1 else: return -1 def check_type2(str_input2): for i in range(len(str_input2)-2): for j in range(i+1,len(str_input2)-2): if str_input2[j]==str_input2[i] and str_input2[j+1]==str_input2[i+1] and str_input2[j+2]==str_input2[i+2]: return -1 else: return 1 a=[] for line in sys.stdin: a.append(line.split("\n")[0]) for i in range(len(a)): if len(a[i])<8: print("NG") elif check_type(a[i])==-1: print("NG") elif check_type2(a[i])==-1: print("NG") else: print("OK")