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

密码验证合格程序

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

import sys
Charmi=['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
charmi=list(map(lambda x:x.lower(),Charmi))
Num=['0','1','2','3','4','5','6','7','8','9']
# print(charmi)
for line in sys.stdin:
    a = line.strip()
    LEN=len(a)>8
    if not LEN: #使用not 和布尔判断,注意continue和break,continue说明换了一行
        print('NG')
        continue

    daxie=not set(a).isdisjoint(set(Charmi)) #isdisjoint函数返回没有交集的判例
    xiaoxie=not set(a).isdisjoint(set(charmi))
    shuzi=not set(a).isdisjoint(set(Num))
    for x in a:
        if x in Charmi or x in charmi or x in Num:
               qita=0
        else:  
            qita=1
            break
    if int(xiaoxie)+int(daxie)+int(shuzi)+qita<3: 
        print('NG')
        continue

    # da=bool(set(a)&set(Charmi))#测试是否交集
    # if not Len:
    #     print('NG')
    # if not (daxie and xiaoxie and shuzi and LEN)
    i=0
    DD={}
    while(i+3<len(a)):
        if a[i:i+3] not in DD: DD[a[i:i+3]]=0
        else: DD[a[i:i+3]]+=1  
        i+=1
    if sum(DD.values())>=1: 
        print('NG')
    else:
        print('OK')
            
    #     print(chong)


全部评论

相关推荐

牛客5655:其他公司的面试(事)吗
点赞 评论 收藏
分享
11-03 14:38
重庆大学 Java
AAA求offer教程:我手都抬起来了又揣裤兜了
点赞 评论 收藏
分享
藏剑天涯:全要了 领4份工资
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务