Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions 18_gematria/solution.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,18 @@ def main():
# --------------------------------------------------
def word2num(word):
"""Sum the ordinal values of all the characters"""

return str(sum(map(ord, re.sub('[^A-Za-z0-9]', '', word))))
word2numList=[]
sum=0
for i in word:
asciinumber=ord(i)
if (i>47 and i<58) or (i>64 and i<123) :
sum+=asciinumber
else:
if i==32:
word2numList.append(sum)
sum=0

return word2numList


# --------------------------------------------------
Expand Down