题解 | #密码验证合格程序#

密码验证合格程序

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

# 哇哈哈,我真是个小天才!!!

import sys
import re

lists = []
for line in sys.stdin:
    line = line.rstrip("\n")
    lists.append(line)

def f(x):
    zt = ""
    count1 = 0
    count=0
    shuzi=re.findall("[0-9]+", x)
    small_zimu=re.findall("[a-z]+", x)
    big_zimu=re.findall("[A-Z]+", x)
    for i in range(len(x) - 3):
        num = x.count(x[i : i + 3])
        if num > 1:
            zt = "NG"
            break
        else:
            pass
    if len(shuzi) > 0:
        for t in range(len(shuzi)):
            count=count+len(shuzi[t])
        count1 += 1
    if len(small_zimu) > 0:
        for t in range(len(small_zimu)):
            count=count+len(small_zimu[t])
        count1 += 1
    if len(big_zimu) > 0:
        for t in range(len(big_zimu)):
            count=count+len(big_zimu[t])
        count1 += 1
    if re.findall(r"\s", x) or re.findall(r"\n", x) or count1 < 3 and count==len(x) or len(x) < 9:
        zt = "NG"
    return zt


lists = list(map(f, lists))
lists=list(map(lambda x:"OK"if x=="" else x,lists))
for i in lists:
    print(i)

全部评论

相关推荐

04-29 22:35
门头沟学院 Java
牛友说改了名字能收到offer:旧图新发查看图片
点赞 评论 收藏
分享
野猪不是猪🐗:我assume that你must技术aspect是solid的,temperament也挺good的,however面试不太serious,generally会feel style上不够sharp
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务