题解 | #名字的漂亮度#

名字的漂亮度

https://www.nowcoder.com/practice/02cb8d3597cf416d9f6ae1b9ddc4fde3

def beautiful(li):
    lw=str(li.lower())
    score=26
    allscore=0
    lc={}
    for each in lw:
        lc[each]=lw.count(each)
    
    lc_s=sorted(lc.values(),reverse=True)   
    
    for each in lc_s:
        allscore+=each*score
        score=score-1
    
    return allscore


num = int(input())
l=[]
for i in range(num):
    l.append(str(input()))
for each in l:
    print(beautiful(each))

全部评论

相关推荐

点赞 收藏 评论
分享
牛客网
牛客企业服务