[프로그래머스] Lv2. 모음사전

lemythe423·2023년 8월 11일
0
post-thumbnail

🔗

풀이

중복순열 product 사용해서 해결. 문자가 5개 밖에 안 되기 때문에 중복순열로 다 구해도 3905개 밖에 안 된다.

def solution(word):
    dic = []
    for r in range(1, 6):
        dic.extend(list(map("".join, product(['A', 'E', 'I', 'O', 'U'], repeat=r))))
        
    dic.sort()
    return dic.index(word)+1
from itertools import product
profile
아무말이나하기

0개의 댓글