feat(solution): problem #22

main
steven 2023-08-01 11:44:24 -04:00
parent 3cd567f386
commit 7025bf4ae6
3 changed files with 19 additions and 0 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,17 @@
from namedata import *
dataTable.sort()
def alpha_value(name):
valueSum = 0
for i in name:
valueSum += (ord(i) - 64) # ord('A') = 65
return valueSum
nameScoreSum = 0
for i in range(len(dataTable)):
nameScore = alpha_value(dataTable[i]) * (i + 1)
nameScoreSum += nameScore
print("The total of all the name scores in the file is: " + str(nameScoreSum))