题解 | #密码强度等级#
密码强度等级
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')
没难度,就是耗时间,条件狂欢属于是 = =|||
'''
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')
【牛客站内】华为机试题—简单 文章被收录于专栏
【牛客站内】华为机试题练习记录