Skip to content

Instantly share code, notes, and snippets.

@gedex
Created January 29, 2013 08:01
Show Gist options
  • Save gedex/4662579 to your computer and use it in GitHub Desktop.
Save gedex/4662579 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import string
import sys
from collections import Counter
ALPHABET = string.ascii_lowercase
def main():
m = int(sys.stdin.readline())
for i in range(m):
b, y = 26, 0
s = [l for l in sys.stdin.readline().strip().lower() if l in ALPHABET]
s = Counter(s).most_common()
for k, v in s:
y = y + v * b
b = b - 1
print "Case #%d: %d" % (i+1, y)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment