[Baekjoon] Recursion 11729.Hanoi-tower#4
Open
seunguri wants to merge 1 commit intoLikeLion-CAU-9th:mainfrom
Open
[Baekjoon] Recursion 11729.Hanoi-tower#4seunguri wants to merge 1 commit intoLikeLion-CAU-9th:mainfrom
seunguri wants to merge 1 commit intoLikeLion-CAU-9th:mainfrom
Conversation
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 free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
처음 든 생각
알고리즘 수업 자료에 있었던 그림이 생각이 난다.
근데 뭐가 적용됐었는 지 기억이 안문제 꼼꼼히 보기
장대 3개 -> a, b, c
원판 개수 1 <= N <= 20
풀이 로직
가장 큰 원판이 c원판으로 가려면 나머지 원판들이 모두 b원판에 있어야함.
나머지 원판이 모두 b원판으로 가려면 2번째로 큰 원판을 제외하고 모두 c원판에 있어야함.
또 그 나머지 원판이 모두 c원판에 가려면 3번째로 큰 원판을 제외하고 모두 b원판에 있어야함.
재귀다!!특이 사항
리스트에 이동과정을 담아서 출력하는 정답을 먼저 생각했는데 재귀이므로 2**n - 1의 이동횟수 를 구할 수 있었다.