Skip to content

Instantly share code, notes, and snippets.

@JungTag
Created October 4, 2021 11:50
Show Gist options
  • Save JungTag/b5a7264330da4930e785e6de1337e929 to your computer and use it in GitHub Desktop.
Save JungTag/b5a7264330da4930e785e6de1337e929 to your computer and use it in GitHub Desktop.
5주차_모음사전 - 영택
# 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