Corrected a few C'isms and also added the solutions to four more problems

This commit is contained in:
MitchellHansen
2017-03-13 22:53:00 -07:00
parent 10b76d0ca6
commit 44358923e3
11 changed files with 183 additions and 7 deletions

20
problem_22.py Normal file
View File

@@ -0,0 +1,20 @@
import ast
# read in the file, convert to a list
f = open('assets/problem_21_names.txt', 'r') # We need to re-open the file
data = ast.literal_eval(f.read())
f.close()
data.sort()
sum = 0
for idx, name in enumerate(data):
word_sum = 0
for letter in name:
word_sum += ord(letter) - 65 + 1
sum += word_sum * (idx+1)
print(sum)