其他分享
首页 > 其他分享> > 牛客华为机试HJ87

牛客华为机试HJ87

作者:互联网

原题传送门

1. 问题描述

2. Solution

import sys

if sys.platform != "linux":
    file_in = open("input/HJ87.txt")
    sys.stdin = file_in


def solve(s):
    counter = dict(lowwer=0, upper=0, num=0, sign=0)
    for c in s:
        if c.islower():
            counter['lowwer'] += 1
        elif c.isupper():
            counter['upper'] += 1
        elif c.isdigit():
            counter['num'] += 1
        else:
            counter['sign'] += 1
    score = 0
    if len(s) <= 4:
        score += 5
    elif 5 <= len(s) <= 7:
        score += 10
    else:
        score += 25

    if counter['lowwer'] != 0 and counter['upper'] != 0:
        score += 20
    elif s.isupper() or s.islower():
        score += 10

    if counter['num'] == 1:
        score += 10
    elif counter['num'] > 1:
        score += 20

    if counter['sign'] == 1:
        score += 10
    elif counter['sign'] > 1:
        score += 25

    if all(counter.values()):
        score += 5
    elif (counter['lowwer'] != 0 or counter['upper'] != 0) and \
            counter['num'] != 0 and counter['sign'] != 0:
        score += 3
    elif counter['lowwer'] != 0 or counter['upper'] != 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")


for line in sys.stdin:
    s = line.strip()
    solve(s)

标签:upper,elif,counter,sign,牛客,score,机试,print,HJ87
来源: https://www.cnblogs.com/junstat/p/16177302.html