Uh oh!
There was an error while loading. Please reload this page.
This repository was archived by the owner on Mar 18, 2024. It is now read-only.
[2023-08-30] wooyeol #161 - #177
Merged
Merged
Conversation
Closed
ksumini
approved these changes
Aug 30, 2023
Contributor
There was a problem hiding this comment.
깔끔한 백트래킹 풀이같아요! 변수명이 직관적이어서 이해가 잘 됐습니다~!!!
zsmalla
approved these changes
Aug 30, 2023
zsmalla
left a comment
Contributor
There was a problem hiding this comment.
재귀에서 매개변수가 복잡해지면 풀이가 비교적 단순해지고, 매개변수가 단순해지면 풀이가 비교적 복잡해지는 특성이 있는 것 같다는 걸 느꼈습니다. 둘 중 어떤 것이 맞고 틀리고가 아닌 본인이 편한 것을 선택하면 좋을 것 같아요. 고생하셨습니다!
Contributor
There was a problem hiding this comment.
개인적으로 정렬된 리스트를 탐색하거나 순서가 정해진 경우의 백트래킹, 재귀에서는 매개변수를 통해 인덱스를 증가시키는 방향으로 재귀를 수행하는 것을 선호합니다. 그러면 별도의 방문 처리가 필요 없거든요!
Contributor
There was a problem hiding this comment.
vowels: Set[str] = {'a', 'e', 'i', 'o', 'u'} 처럼 작성해도 좋을 것 같습니다. 저도 몰랐었는데 PEP8에서 리스트나 셋을 선언할 때 a=set() 이렇게 선언하는 것을 지양하더라구요! set() 이나 list() 키워드는 형변환 할 때에만 사용하고 선언 시에는 braket만 써도 좋을 것 같습니다!
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
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Summary
암호 만들기
https://www.acmicpc.net/problem/1759
풀이시간
10:52 ~ 11:43 (49분)
문제 조건
3 <= L <= C <= 15
L개의 알파벳 소문자 (최소 한 개의 모음과 두 개의 자음)
시간 복잡도 : O(L x C)
접근법
무슨 알고리즘으로 풀이 할 수 있을까? -> 백 트래킹
백트래킹을 구현하며 Base Condition(길이가 L과 같고 모음의 갯수가 0보다 크고 자음의 갯수가 1보다 클 경우)일 경우만 값을 출력
백 트래킹을 위한 검사문들을 작성한다.
중복을 허용하지 않고 알파벳 사전순일 경우만 확인하기 때문에 현재 담겨있는 알파벳보다 더 큰 인덱스 값만 검사한다.
방문하지 않은 알파벳일 경우
2-1. 현재 위치를 방문 처리하고 해당 값을 Password에 넣은 뒤 자음과 모음 갯수를 업데이트한다.
2-2. 다음 자리 알파벳을 백 트래킹으로 찾는다.
2-3. 탐색된 알파벳을 방문처리를 해제하고 자,모음 갯수를 다시 업데이트 한다.