From 7b624de8e3e3637a07364f992c1d7e4185e4a872 Mon Sep 17 00:00:00 2001 From: Charles Date: Sun, 11 Aug 2019 18:42:52 +0200 Subject: initial commit --- python/22-names_scores.py | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 python/22-names_scores.py (limited to 'python/22-names_scores.py') diff --git a/python/22-names_scores.py b/python/22-names_scores.py new file mode 100644 index 0000000..7bba853 --- /dev/null +++ b/python/22-names_scores.py @@ -0,0 +1,9 @@ +names = [] +with open('./helper/data/names.txt', 'r') as file: + names = sorted([n[1:-1] for n in file.read().split(',')]) + +total = 0 +for i, name in enumerate(names): + total += sum([ord(s) - 64 for s in name]) * (i + 1) + +print(total) -- cgit