题解 | #密码强度等级#

密码强度等级

http://www.nowcoder.com/practice/52d382c2a7164767bca2064c1c9d5361

暴力解法

while True:
    try:
        pc = input()
        grade = alp = res = num = sym = 0
        if len(pc) <= 4:
            grade += 5
        elif len(pc) <= 7:
            grade += 10
        else:
            grade += 25

        for i in pc:
            if i.islower():
                res += 1
                break
        for i in pc:
            if i.isupper():
                res += 1
                break
        if res == 2:
            alp += 20
        elif res == 1:
            alp += 10
        grade += alp
        for i in pc:
            if i.isdigit():
                num += 1
            elif not i.isalpha():
                sym += 1
        if num == 1:
            grade += 10
        elif num > 1:
            grade += 20
        if sym == 1:
            grade += 10
        elif sym > 1:
            grade += 25
        if alp == 20 and num > 0 and sym >0:
            grade += 5
        elif alp == 10 and num > 0 and sym >0:
            grade += 3
        elif alp == 10 and num > 0:
            grade += 2
        if grade >= 90:
            print("VERY_SECURE")
        elif grade >= 80:
            print("SECURE")
        elif grade >= 70:
            print("VERY_STRONG")
        elif grade >= 60:
            print("STRONG")
        elif grade >= 50:
            print("AVERAGE")
        elif grade >= 25:
            print("WEAK")
        else:
            print("VERY_WEAK")
    except:
        break
全部评论

相关推荐

沉淀一会:1.同学你面试评价不错,概率很大,请耐心等待; 2.你的排名比较靠前,不要担心,耐心等待; 3.问题不大,正在审批,不要着急签其他公司,等等我们! 4.预计9月中下旬,安心过节; 5.下周会有结果,请耐心等待下; 6.可能国庆节前后,一有结果我马上通知你; 7.预计10月中旬,再坚持一下; 8.正在走流程,就这两天了; 9.同学,结果我也不知道,你如果查到了也告诉我一声; 10.同学你出线不明朗,建议签其他公司保底! 11.同学你找了哪些公司,我也在找工作。
点赞 评论 收藏
分享
评论
1
收藏
分享
牛客网
牛客企业服务