You are viewing a single comment's thread. Return to all comments →
letters = {"ABCDEFGHIJKLMNOPQRSTUVWXYZ"[i] : i + 1 for i in range(26)} names = [] def score(name): return sum(letters[letter] for letter in name) n = int(input()) for i in range(n): names.append(input()) names.sort() scores = {name: score(name) * (index + 1) for index, name in enumerate(names)} q = int(input()) for _ in range(q): print(scores[input()])
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #22: Names scores
You are viewing a single comment's thread. Return to all comments →