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

密码验证合格程序

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

while True:
    try:
        st=input()
        if len(st)<8:
            print('NG')
            continue
        ad = 0
        NG=False
        lowercase=False
        uppercase=False
        number=False
        special=False
        for i in range(len(st)):
            #print(st[i],lowercase,uppercase,number,special)
            if st[i]>='a' and st[i]<='z':
                if not lowercase:
                    ad+=1
                    lowercase=True
            elif st[i]>='A' and st[i]<='Z':
                if not uppercase:
                    uppercase=True
                    ad+=1
            elif st[i]>='0' and st[i]<='9' :
                if not number:
                    number=True
                    ad+=1
            elif not special:
                special = True
                ad+=1
        if ad < 3:
            print('NG')
            NG = True
            continue
        for i in range(len(st)-3):
            for j in range(i+3, i+len(st)-i//2+1):
                if st[i:j] in st[j+2:len(st)]:
                    print('NG')
                    #print (st[i:j])
                    NG = True
                    break
            if NG==True:
                break
        if NG==False:
            print('OK')

    except:
        break


全部评论

相关推荐

不要停下啊:大二打开牛客,你有机会开卷了,卷起来,去找课程学习,在牛客上看看大家面试笔试都需要会什么,岗位有什么需求就去学什么,努力的人就一定会有收获,这句话从来都经得起考验,像我现在大三了啥也不会,被迫强行考研,炼狱难度开局,啥也不会,找工作没希望了,考研有丝丝机会
点赞 评论 收藏
分享
qq乃乃好喝到咩噗茶:院校后面加上211标签,放大加粗,招呼语也写上211
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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