코테/프로그래머스

프로그래머스 모음사전

밤밭황제 2022. 12. 26. 17:09
def solution(word):
    answer = 0
    one  = 1 + 5 + 5**2 + 5**3 + 5**4
    two = 1 + 5 + 5**2 + 5**3
    three = 1 + 5 + 5**2
    four = 1 + 5
    cal = [ one, two, three, four, 1]
    lst = list(word)
    alpha = {'A':0, 'E':1, 'I':2, 'O':3, 'U': 4}
    
    for i in range(0, len(lst)):
        if lst[i] == 'A':
            answer += 1
        else:
            answer += cal[i] * alpha[lst[i]] + 1

    return answer
728x90