Skip to content
This repository was archived by the owner on Mar 18, 2024. It is now read-only.

[2023-09-18] sumin #237 #249

Merged
merged 1 commit into from
Sep 19, 2023
Merged

[2023-09-18] sumin #237 #249

merged 1 commit into from
Sep 19, 2023

Conversation

ksumini
Copy link
Contributor

@ksumini ksumini commented Sep 18, 2023

PR Summary

풀이시간: 10분

<input>
word: 단어 하나

  • 길이는 1 이상 5 이하
  • 알파벳 대문자 'A', 'E', 'I', 'O', 'U'로만 이루어져 있음

<solution>
만들 수 있는 모든 단어를 만들어도 5**5 = 3125밖에 되지 않기 때문에,
모든 단어를 브루트포스로 만들어 해당 단어가 몇 번째 단어인지 확인한다.

<시간복잡도>
O(5 ** 5) = O(3125) -> O(1): 상수시간
사전을 만드는데 가장 오랜 시간이 걸린다.

Copy link
Contributor

@limstonestone limstonestone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

확실히 재귀로 풀어내니 직관적이네요!!
감사합니다 수민님!


def solution(word: str) -> int:
go(0, '')
for i, w in enumerate(dic, start=1):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

start=1 이라는 옵션은 처음 보네요!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

222222 이러면 인덱스가 1부터 시작하군요..
(근데 22222 이거 쓰면 요새 틀딱이래요)

- 알파벳 대문자 'A', 'E', 'I', 'O', 'U'로만 이루어져 있음

<solution>
만들 수 있는 모든 단어를 만들어도 5**5 = 3125밖에 되지 않기 때문에,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

굳이 따지자면(?) 모든 단어의 길이가 5가 아니기 때문에 경우의수가 더 늘어나긴 합니다!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

옹 5!이 맞는 것 같아요!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

제 코드상으로 굳이 따지면 5^6이긴한데 어차피 return되니까 5^5로 생각했어요!
image
5!은 아니에요!!

Copy link
Contributor

@zsmalla zsmalla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

깔끔하고 효율적인 DFS 풀이였습니다! DFS 함수에서 조금 더 최적화할 수 있는 방안에 대해서 코멘트 달아두었으니 참고해주시면 좋을 것 같아요. 아픈데도 수고 많으셨습니다 수민님!

- 알파벳 대문자 'A', 'E', 'I', 'O', 'U'로만 이루어져 있음

<solution>
만들 수 있는 모든 단어를 만들어도 5**5 = 3125밖에 되지 않기 때문에,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

옹 5!이 맞는 것 같아요!


mo = "AEIOU"
dic = []
def go(index: int, alpha: str) -> None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

go 함수 내부에서 len(alpha)를 계산한다면 index 매개변수는 안써도 되어 조금 더 좋을 것 같습니다!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

재귀 짤때마다 index넘겨주는게 습관이 돼서 다음번 부터는 len을 써보겠습니다..!! 감사합니다 지수님:)


def solution(word: str) -> int:
go(0, '')
for i, w in enumerate(dic, start=1):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

222222 이러면 인덱스가 1부터 시작하군요..
(근데 22222 이거 쓰면 요새 틀딱이래요)


mo = "AEIOU"
dic = []
def go(index: int, alpha: str) -> None:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

와 재귀를 생각하신건 정말 대단하신 것 같아요 재귀의 특성을 정확히 이해하고 계신 것에 감탄이 나옵니다.

@ksumini ksumini linked an issue Sep 18, 2023 that may be closed by this pull request
@ksumini ksumini merged commit 556493b into main Sep 19, 2023
@ksumini ksumini deleted the sumin-#237 branch September 19, 2023 10:39
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Programmers] 모음사전
4 participants