题解 | #密码验证合格程序#
密码验证合格程序
https://www.nowcoder.com/practice/184edec193864f0985ad2684fbc86841
#哇,这道中等题我居然一次就过了,可喜可贺! import sys for line in sys.stdin: a = line.split() if len(a[0]) <= 8: print("NG") continue three_four = 0 for i in a[0]: if i.islower(): three_four += 1 break for i in a[0]: if i.isnumeric(): three_four += 1 break for i in a[0]: if i.isupper(): three_four += 1 break for i in a[0]: if i.isalpha() or i.isnumeric() or i.isupper(): three_four = three_four else: three_four += 1 break if three_four < 3: print("NG") continue seen_substrings = set() more = False for i in range(len(a[0]) - 2): substring = a[0][i : i + 3] if substring in seen_substrings: print('NG') break seen_substrings.add(substring) if i == len(a[0]) - 3: print('OK') break