Created
January 24, 2015 06:35
-
-
Save sarchertech/2ad6ffa991c4dcdb87d0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def answer(names): | |
names_with_sums = [] | |
for name in names: | |
names_with_sums.append([word_to_sum(name), name]) | |
names_with_sums.sort(reverse=True) | |
sorted_names = [] | |
for item in names_with_sums: | |
sorted_names.append(item[1]) | |
return sorted_names | |
def word_to_sum(str): | |
sum = 0 | |
offset = ord("a") - 1 | |
for c in str: | |
sum += (ord(c)-offset) | |
return sum |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment