Project Euler #22: Names scores

  • + 0 comments

    100% python code

    n = int(input())
    names = list(sorted([input() for _ in range(n)]))
    q = int(input())
    alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    for _ in range(q):
        name = input()
        value = 0
        for letter in name:
            value += alphabet.index(letter) + 1
        value *= (names.index(name) + 1)
        print(value)