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面试的专属专栏,我会把自己的解法更新在里面,我会尽量写清楚自己的思路以及多写关键注释,希望对阅读的人有帮助~~~

全部评论

相关推荐

05-05 21:45
已编辑
广州大学 Java
点赞 评论 收藏
分享
AAA专业长城贴瓷砖刘大爷:这样的简历我会直接丢进垃圾桶,花里胡哨的
点赞 评论 收藏
分享
投递快手等公司10个岗位 > 晒一晒你收到的礼盒
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务