题解 | #密码强度等级#

走方格的方案数

http://www.nowcoder.com/practice/e2a22f0305eb4f2f9846e7d644dba09b

暴力解法 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
全部评论

相关推荐

02-05 08:49
已编辑
武汉大学 Java
野猪不是猪🐗:36k和36k之间亦有差距,ms的36k和pdd的36k不是一个概念
点赞 评论 收藏
分享
大摆哥:刚好要做个聊天软件,直接让你帮他干活了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务