题解 | 密码验证合格程序

密码验证合格程序

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

import sys
import re

for line in sys.stdin:
    pw = line.strip()
    if len(pw) < 8:
        print('NG')
        continue
    a, b, c = re.search(r'[A-Z]', pw), re.search(r'[a-z]', pw), re.search(r'[0-9]', pw)
    re_pw = ''.join([chr(x) for x in range(33, 127)])
    re_pw = re_pw[:15] + re_pw[25:32] + re_pw[58:64] + re_pw[90:]
    d = re.search(rf'[{re_pw}]', pw)
    if not (a and b and c or a and b and d or a and c and d or b and c and d):
        print('NG')
        continue
    x = False
    for i in range(len(pw) - 6):
        if pw.count(pw[i:i+3]) > 1:
            x = True
            break
    if x:
        print('NG')
        continue
    print('OK')

全部评论

相关推荐

03-23 15:00
已编辑
厦门大学 Java
xiaowl:你这个简历的问题是对于技术点、项目的描述,都是描述action的,对于面试官而言,仅能知道你干了什么,无法判断你为什么这么干,干的好不好。
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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