Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5942c55

Browse files
committed
refactored
1 parent 8b344d8 commit 5942c55

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

18_gematria/gematria.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,23 @@ def get_args():
3333

3434

3535
def calc(word):
36-
return str(sum([ord(c) for c in word]))
36+
return str(sum(map(ord, word)))
3737

3838
def test_calc():
3939
assert calc("AA") == 130
4040
assert calc("ddd") == 300
4141
# --------------------------------------------------
42+
def convertWord(input):
43+
return calc(re.sub('[^A-Za-z0-9]', '', input))
44+
4245
def main():
4346
"""Make a jazz noise here"""
4447

4548
args = get_args()
4649
text = args.text
4750

4851
for line in args.text.splitlines():
49-
# print(list(map(lambda x: calc(re.sub('[^A-Za-z0-9]', '', x)), line.split())))
50-
print(' '.join(map(lambda x: calc(re.sub('[^A-Za-z0-9]', '', x)), line.split())))
52+
print(' '.join(map(convertWord, line.split())))
5153

5254

5355
# --------------------------------------------------

0 commit comments

Comments
 (0)