当前位置: 首页 > 面试经验 >

雷火 数据挖掘-笔试

优质
小牛编辑
149浏览
2023-03-28

雷火 数据挖掘-笔试

2道编程共40分,5道问答110分,共两个半小时,没做多久就退出来,哎。。。
有一道编程题用例过了,一提交通过0个用例,麻了
大佬给看看:
题目是车牌号识别准确率计算
输入N个车牌号,第一个字母是颜色,最后5个是号码,中间是地区号
每一行一个识别出的号码,一个真实标签
n = int(input())
def same_str(str1,str2):
    l = len(str1)
    result = 0
    for i in range(l):
        for j in range(l):
            if str1[i] == str2[j]:
                left = i
                right = j
                tmp = 0
                while (left < n and right < n):
                    if str1[left] == str2[right]:
                        tmp += 1
                        left += 1
                        right += 1
                        result = max(result,tmp)
                    else:
                        break
    return result
ans = 0
ii = 0
while ii < n:
    try:
        temp = 0
        label, true = input().strip().split()
        if label[0] == true[0]:
            temp += 2
        if label[1:-5] == true[1:-5]:
            temp += 3
        temp += same_str(label[-5:],true[-5:])
        ans += temp / 10 * 100
        ii += 1
    except:
        break

print("{:.2f}%".format(round(ans / n,2)))


#我的秋招日记##网易雷火笔试##23届秋招笔面经#
 类似资料: