HJ87 题解 | #密码强度等级#
密码强度等级
https://www.nowcoder.com/practice/52d382c2a7164767bca2064c1c9d5361
#Tips:判断字符串全是大写str.isupper(),小写为str.lower()
def length(s):
if len(s)<=4:
return 5
elif 5<=len(s)<=7:
return 10
else:
return 25
def letter(s):
l=""
for i in s:
if i.isalpha():
l+=i
if len(l)==0:
return 0
else:
if l.isupper() or l.islower():
return 10
else:
return 20
def number(s):
l=""
for i in s:
if i.isdigit():
l+=i
if len(l)==0:
return 0
elif len(l)==1:
return 10
else:
return 20
def fu(s):
l=""
for i in s:
if i.isdigit() or i.isalpha():
continue
else:
l+=i
if len(l)==0:
return 0
elif len(l)==1:
return 10
else:
return 25
def jiang(s):
if letter(s)==20 and number(s)>=10 and fu(s)>=10:
return 5
elif letter(s)==10 and number(s)>=10 and fu(s)>=10:
return 3
elif letter(s)>=10 and number(s)>=10:
return 2
else:
return 0
def check(n):
if n>=90:
print("VERY_SECURE")
elif n>=80:
print("SECURE")
elif n>=70:
print("VERY_STRONG")
elif n>=60:
print("STRONG")
elif n>=50:
print("AVERAGE")
elif n>=25:
print("WEAK")
else:
print("VERY_WEAK")
s=input()
n=length(s)+letter(s)+number(s)+fu(s)+jiang(s)
check(n)
#华为##华为od##华为机试##华为od机试#华为HJ103所有解法 文章被收录于专栏
这是我准备华为od面试的专属专栏,我会把自己的解法更新在里面,我会尽量写清楚自己的思路以及多写关键注释,希望对阅读的人有帮助~~~

美团成长空间 2667人发布