23 lines
468 B
Python
23 lines
468 B
Python
|
def beautiful_s(string):
|
||
|
A = count_occ(string)
|
||
|
A.sort()
|
||
|
count = 0
|
||
|
for i in range(0, 26):
|
||
|
count = count + (A[i]*(i+1))
|
||
|
return count
|
||
|
|
||
|
|
||
|
def count_occ(string):
|
||
|
A = [0]*26
|
||
|
for char in string:
|
||
|
u = char.upper()
|
||
|
if u.isupper():
|
||
|
A[ord(u) - ord("A")] += 1
|
||
|
return A
|
||
|
|
||
|
|
||
|
if __name__ == "__main__":
|
||
|
n = int(input())
|
||
|
for i in range(1,n+1):
|
||
|
print("Case #" + str(i) + ": " + str(beautiful_s(input())))
|