«   2025/09   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
Recent Posts
Tags more
Today
Total
관리 메뉴

내 인생은 개발 중

[프로그래머스] 모음사전 - Python 본문

Algorithm/프로그래머스

[프로그래머스] 모음사전 - Python

seul.e 2024. 7. 3. 22:14

https://school.programmers.co.kr/learn/courses/30/lessons/84512

 

프로그래머스

코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.

programmers.co.kr

 

 

from itertools import product
def solution(word):
    dict = []
    vowels = ['A', 'E', 'I', 'O', 'U']
    for i in range(1, 6):
        for v in product(vowels, repeat = i):
            dict.append(''.join(list(v)))
    dict.sort()
    return dict.index(word) + 1

💡알게 된 점💡

product를 사용하면 중복 순열을 구할 수 있다.
repeat은 몇번까지 반복을 허용하는지 뜻한다.

Comments