반응형
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 31 |
Tags
- BFS
- 파이썬
- level1
- 그리디
- 재귀
- programmers
- MYSQL
- 구현
- level3
- 스택
- DP
- 딕셔너리
- 가상메모리
- N과M
- 운영체제
- 브루트포스
- 다익스트라
- python
- 프로그래머스
- 백준
- BOJ
- level2
- dfs
- 코딩테스트
- 힙
- 다이나믹 프로그래밍
- 가상메모리 관리
- 수학
- level0
- 에라스토테네스의 체
Archives
- Today
- Total
동캄의 코딩도장
프로그래머스 level2 [모음사전] 파이썬 본문
반응형
https://programmers.co.kr/learn/courses/30/lessons/84512
코딩테스트 연습 - 모음사전
사전에 알파벳 모음 'A', 'E', 'I', 'O', 'U'만을 사용하여 만들 수 있는, 길이 5 이하의 모든 단어가 수록되어 있습니다. 사전에서 첫 번째 단어는 "A"이고, 그다음은 "AA"이며, 마지막 단어는 "UUUUU"입니
programmers.co.kr
#프로그래머스 모음사전
def solution(word):
import sys
sys.setrecursionlimit(10**6)
vowels=['A','E','I','O','U']
global cnt
global answer
answer = 0
cnt=0
string=''
def dfs(w):
global cnt
global answer
cnt+=1
if w==word:
answer=cnt
if len(w)==5:
return
else:
for i in range(5):
dfs(w+vowels[i])
for i in range(5):
dfs(vowels[i])
return answer
dfs로 탐색했다.
반응형
'코테 > 프로그래머스' 카테고리의 다른 글
프로그래머스 level2 [예상 대진표] 파이썬 (0) | 2021.12.07 |
---|---|
프로그래머스 level2 [영어 끝말잇기] 파이썬 (0) | 2021.12.07 |
프로그래머스 level2 [주식가격] 파이썬 (0) | 2021.12.07 |
프로그래머스 level2 [괄호 회전하기] 파이썬 (0) | 2021.12.06 |
프로그래머스 level2 [짝지어 제거하기] 파이썬 (0) | 2021.12.06 |