题解 | #密码验证合格程序#简单易懂解法

密码验证合格程序

https://www.nowcoder.com/practice/184edec193864f0985ad2684fbc86841

import sys
for line in sys.stdin:
    password = line
    length = len(password)
    if  length <= 8:
        print('NG')
        continue
    else:
        typ = [False, False, False, False]
        abc = 'abcdefghijklmnopqrstuvwxyz'
        repeat_ = False
        for i in range(length-2):
            if password[i]+password[i+1]+password[i+2] in password[i+3:]:
                repeat_ = True
                break
            if password[i] in abc:
                typ[0] = True
            elif password[i] in abc.upper():
                typ[1] = True
            elif password[i] in '0123456789':
                typ[2] = True
            else:
                typ[3] = True
        if repeat_:
            print('NG')
        elif sum(typ)<3 :
            print('NG')
        else :
            print('OK')
全部评论

相关推荐

04-01 11:08
中原工学院 Java
老六f:感觉这种培训期过了就找理由给你开了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务