Skip to content

Instantly share code, notes, and snippets.

@sarchertech
Created January 24, 2015 06:35
Show Gist options
  • Save sarchertech/2ad6ffa991c4dcdb87d0 to your computer and use it in GitHub Desktop.
Save sarchertech/2ad6ffa991c4dcdb87d0 to your computer and use it in GitHub Desktop.
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