题解 | #密码强度等级#

密码强度等级

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

'''
没难度,就是耗时间,条件狂欢属于是 = =|||
'''
i = input()
cd = 0
sz = 0
xx = 0
dx = 0
fh = 0

for k in i:
    if k.isdigit():
        sz=sz+1
    elif k.islower():
        xx=xx+1
    elif k.isupper():
        dx=dx+1
    else:
        fh=fh+1
cd=len(i)

goal = 0

if cd<=4:
    goal=goal+5
elif 5<=cd<=7:
    goal=goal+10
else:
    goal=goal+25

if xx==0 and dx==0:
    goal=goal+0
elif (xx==0 and dx!=0)or(xx!=0 and dx==0):
    goal=goal+10
else:
    goal=goal+20
    
if sz==0:
    goal=goal+0
elif sz==1:
    goal=goal+10
else:
    goal=goal+20

if fh==0:
    goal=goal+0
elif fh==1:
    goal=goal+10
else:
    goal=goal+25

if (xx+dx)!=0 and sz!=0 and fh==0:
    goal=goal+2
elif (xx==0 and dx!=0 and sz!=0 and fh!=0)or(xx!=0 and dx==0 and sz!=0 and fh!=0):
    goal=goal+3
elif xx!=0 and dx!=0 and sz!=0 and fh!=0:
    goal=goal+5
    
if goal>=90:
    print('VERY_SECURE')
elif goal>=80:
    print('SECURE')
elif goal>=70:
    print('VERY_STRONG')
elif goal>=60:
    print('STRONG')
elif goal>=50:
    print('AVERAGE')
elif goal>=25:
    print('WEAK')
else:
    print('VERY_WEAK')
    

【牛客站内】华为机试题练习记录

全部评论

相关推荐

10-14 23:01
已编辑
中国地质大学(武汉) Java
CUG芝士圈:虽然是网上的项目,但最好还是包装一下,然后现在大部分公司都在忙校招,十月底、十一月初会好找一些。最后,boss才沟通100家,别焦虑,我去年暑假找第一段实习的时候沟通了500➕才有面试,校友加油
点赞 评论 收藏
分享
1 2 评论
分享
牛客网
牛客企业服务