Created
October 4, 2021 11:50
-
-
Save JungTag/b5a7264330da4930e785e6de1337e929 to your computer and use it in GitHub Desktop.
5주차_모음사전 - 영택
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://programmers.co.kr/learn/courses/30/lessons/84512 | |
import sys | |
sys.setrecursionlimit(10**6) | |
def solution(word): | |
global cnt | |
global answer | |
answer = 0 | |
cnt = 0 | |
alphabets = ['A', 'E', 'I', 'O', 'U'] | |
visited = set([]) | |
def dfs(cur): | |
global cnt | |
global answer | |
visited.add(cur) | |
cnt += 1 | |
if cur == word: | |
answer = cnt | |
return | |
if len(cur) >= 5: | |
return | |
for alphabet in alphabets: | |
_next = cur + alphabet | |
if _next not in visited: | |
dfs(_next) | |
for alphabet in alphabets: | |
dfs(alphabet) | |
return answer |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment