题解 | #密码验证合格程序# Python3:各种复杂判断
密码验证合格程序
https://www.nowcoder.com/practice/184edec193864f0985ad2684fbc86841
import sys if __name__ == "__main__": for line in sys.stdin: s = line.strip() n = len(s) # 判断长度 if n > 8: # 判断符号种类 char_type = set() for c in s: if c.islower(): char_type.add("lower") elif c.isupper(): char_type.add("upper") elif c.isnumeric(): char_type.add("numeric") else: char_type.add("other") if len(char_type) >= 3: # 判断子串重复 left = 0 flag = False while left < n - 4 and not flag: right = left + 1 while right < n - 1 and not flag: if s[left] == s[right]: cnt = 0 i, j = left, right while i < n and j < n and s[i] == s[j]: i += 1 j += 1 cnt += 1 if cnt > 2: flag = True break right += 1 left += 1 if flag: print("NG") else: print("OK") else: print('NG') else: print('NG')#23届找工作求助阵地##软件开发薪资爆料##我的实习求职记录##你们的毕业论文什么进度了#
算法之路 文章被收录于专栏
有关数据结构、算法等的文章