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

密码验证合格程序

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


全部评论

相关推荐

10-17 12:16
同济大学 Java
7182oat:快快放弃了然后发给我,然后让我也泡他七天最后再拒掉,狠狠羞辱他一把😋
点赞 评论 收藏
分享
尊嘟假嘟点击就送:加v细说,问题很大
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务