내 풀이
#중복순열
from itertools import product
def solution(word):
answer = 0
d = []
for i in range(5):
d += list(map(''.join, product("AEIOU", repeat = i + 1)))
d.sort()
return d.index(word) + 1
코드길이 더 줄인 풀이 - 리스트 컴프리헨션
#중복순열
from itertools import product
def solution(word):
answer = 0
d = sorted([''.join(c) for i in range(5) for c in product("AEIOU", repeat = i + 1)])
return d.index(word) + 1
'개발 > Algorithm' 카테고리의 다른 글
| [프로그래머스/42885/level2/고득점kit] 구명보트 - 그리디, 두 포인터 사용 (0) | 2023.08.14 |
|---|---|
| [프로그래머스/42860/level2/고득점kit] 조이스틱 - 그리디 (0) | 2023.08.12 |
| [프로그래머스/86971/level2/고득점kit] 전력망을 둘로 나누기 - 완전탐색, BFS (0) | 2023.08.10 |
| [백준/기본기 다지기(2)] 최대공약수(유클리드 호제)&최소공배수, 브루트포스, 피보나치 수(재귀) (0) | 2023.08.08 |
| [프로그래머스/87946/level2/고득점kit] 피로도 - DFS, 완전탐색 (0) | 2023.08.08 |