[Python] 프로그래머스 / level 2 / 모음사전 / 재귀함수 / 중복순열 / 리스트 순서대로 인덱스 반환
2024. 4. 6. 08:10ㆍCoding Test/Python
https://school.programmers.co.kr/learn/courses/30/lessons/84512
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
from itertools import product
def solution(word):
dictionary = []
for i in range(1,6):
for j in product(['A', 'E', 'I', 'O', 'U'], repeat=i):
dictionary.append(''.join(list(j)))
dictionary.sort()
return dictionary.index(word)+1
def solution(word):
dictionary = []
moum = 'AEIOU'
def recursive(cnt, w):
if cnt==5:
return
for i in range(len(moum)):
dictionary.append(w + moum[i])
recursive(cnt+1, w+moum[i])
recursive(0, "")
return dictionary.index(word)+1
'Coding Test > Python' 카테고리의 다른 글
| [Python] 프로그래머스 / level 1 / 그리디 / 체육복 (0) | 2024.07.29 |
|---|---|
| [Python] 프로그래머스 / 모음 사전 / DFS (0) | 2024.07.22 |
| [Python] 프로그래머스 / level 2 / 완전탐색 / 구현 / 소수찾기 / 리스트 내 모든 순열 구하기 (0) | 2024.04.04 |
| [Python] 프로그래머스 / level 1 / 체육복 / 그리디 / 반례 (1) | 2024.03.29 |
| [Python] 프로그래머스 / level 4 / 무지의 먹방 라이브 / heapq / 그리디 (0) | 2024.03.29 |