题解 | #密码强度等级#

密码强度等级

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

a = input()

score = 0

# length
if len(a) <= 4:
    score += 5
elif len(a) <= 7:
    score += 10
else:
    score += 25

jarge = [0,0,0,0]  # xiaoxie, daxie, shuzi, fuhao
for i in a:
    if ord('a') <= ord(i) <= ord('z'):
        jarge[0] += 1
    elif ord('A') <= ord(i) <= ord('Z'):
        jarge[1] += 1
    elif ord('0') <= ord(i) <= ord('9'):
        jarge[2] += 1
    else:
        jarge[3] += 1

# 字母
if jarge[0] == 0 and jarge[1] == 0: # 没有字母
    score += 0 
elif (jarge[0] == 0 and jarge[1] >0) or (jarge[1] == 0 and jarge[0] >0): #全都是小(大)写字母
    score += 10
elif jarge[0] > 0 and jarge[1] > 0: # 大小写混合
    score += 20

# 数字
if jarge[2] == 0: # 没有数字
    score += 0
elif jarge[2] == 1: # 1个数字
    score += 10
elif jarge[2] > 1:
    score += 20

# 符号
if jarge[3] == 0: # 没有符号
    score += 0
elif jarge[3] == 1: # 1个符号
    score += 10
elif jarge[3] > 1:
    score += 25

if jarge[0]>0 and jarge[1]>0 and jarge[2]>0 and jarge[3]>0:
    score += 5
elif (jarge[0]>0 or jarge[1]>0) and jarge[2]>0 and jarge[3]>0:
    score += 3
elif (jarge[0]>0 or jarge[1]>0) and jarge[2]>0:
    score += 2

if score >= 90:
    print('VERY_SECURE')
elif score >= 80:
    print('SECURE')
elif score >= 70:
    print('VERY_STRONG')
elif score >= 60:
    print('STRONG')
elif score >= 50:
    print('AVERAGE')
elif score >= 25:
    print('WEAK')
elif score >= 0:
    print('VERY_WEAK')

全部评论

相关推荐

当年还在美团那个倒霉的&nbsp;Peppr&nbsp;团队工作时,我一直有个疑问:这群人每天到底在自嗨什么。每次开会一堆人围着一堆“看起来很高级”的文档转,模板统一、名词复杂、页数感人,每一页都在暗示一件事:“你不懂,是因为你不专业。”但现实是——代码照样写在&nbsp;💩&nbsp;山上,该出问题还是会出问题,这真的很逗,系统一出问题,文档的唯一作用就是证明:“我们当初确实认真写过文档。”所以本质区别到底是什么?是代码质量提升了,还是大家在精神层面完成了一次“工程师&nbsp;cosplay”?有句话说得好潮水退去才知道谁在裸泳。还记得当时的马哥、明哥(图&nbsp;1&nbsp;左)最爱反复强调一句话:“所有场景一定要想到。”、“这个场景为什么没考虑到?”不过他们这些话我是真的听进去了。不然我也不会在一年多前就说:这个项目活不过两年。顺带一提,那段时间还有个固定节目。每次下楼,总能听见我明哥在吐槽不同的人。我从他身后绕过去,经常能听到他一边抽烟一边说:“xx&nbsp;这小子太坑了,回头我一定要跟马哥说说。”于是深谙人情世故但真不会抽烟的我也会从口袋掏出一支低尼古丁含量的烟给自己点上,假意自己什么都没听到什么都不知道,只是来抽烟的。后来我才明白,这可能也是团队文化的一部分:问题永远在别人身上,而我们,永远在复盘里😂。
秋招白月光
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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