题解 | #杨辉三角的变形#

密码强度等级

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

先整理出都有什么,然后再去计算

    try:
        strA = []
        stra = []
        num1 = []
        fu1 = []
        out = 0
        s = input()
        for i in s:

            if i.isdigit():  # 是否为数字
                num1.append(i)
            elif i.islower():  # 为小写
                stra.append(i)
            elif i.isupper():  # 为大写
                strA.append(i)
            # 是否为字符
            elif 0x21 <= ord(i) <= 0x2F or 0x3A <= ord(i) <= 0x40 or 0x5B <= ord(i) <= 0x60 or 0x7B <= ord(i) <= 0x7E:
                fu1.append(i)
        if 1 <= len(s) <= 4:
            out += 5
        elif 5 <= len(s) <= 7:
            out += 10
        elif len(s) >= 8:
            out += 25

        if len(strA + stra) > 0:
            if len(strA + stra) == len(strA) or len(strA + stra) == len(stra):
                out += 10
            else:
                out += 20

        if len(num1) == 1:
            out += 10
        elif len(num1) > 1:
            out += 20

        if len(fu1) == 1:
            out += 10
        elif len(fu1) > 1:
            out += 25

        if len(strA + stra) > 0 and len(num1) > 0:
            if len(strA) > 0 and len(stra) > 0 and len(fu1) > 0:
                out += 5
            if (len(strA + stra) == len(strA) or len(strA + stra) == len(stra)) and len(fu1) > 0:
                out += 3
            else:
                out += 2

        if out >= 90:
            print('VERY_SECURE')
        elif 90 > out >= 80:
            print('SECURE')
        elif 80 > out >= 70 :
            print('VERY_STRONG')
        elif 70 > out >= 60 :
            print('STRONG')
        elif 60 > out >= 50:
            print('AVERAGE')
        elif 50 > out >= 25:
            print('WEAK')
        else:
            print('VERY_WEAK')
    except:
        break

全部评论

相关推荐

头顶尖尖的程序员:我是26届的不太懂,25届不应该是找的正式工作吗?为什么还在找实习?大四还实习的话是为了能转正的的岗位吗
点赞 评论 收藏
分享
仁者伍敌:服务员还要脱颖而出,这是五星级酒店吗
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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