From 6c0a8a20d2b18a8fb99b6a3acb6b17831a67145a Mon Sep 17 00:00:00 2001 From: tommi27 Date: Thu, 11 Apr 2019 16:39:14 +0200 Subject: [PATCH] done amazingly stunning heartmelting strings (problem I) --- bootiful_strings.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 bootiful_strings.py diff --git a/bootiful_strings.py b/bootiful_strings.py new file mode 100644 index 0000000..a12ef30 --- /dev/null +++ b/bootiful_strings.py @@ -0,0 +1,22 @@ +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())))