This repository was archived by the owner on Mar 18, 2024. It is now read-only.
[2023-10-13] wooyeol #332#333
Merged
Merged
Conversation
Closed
zsmalla
approved these changes
Oct 14, 2023
Contributor
zsmalla
left a comment
There was a problem hiding this comment.
swife와 merge 과정을 별도의 자료구조(queue)를 두어 보다 편리하게 구현하신 점이 인상깊었던 풀이었습니다. 메모리가 넉넉하다면 이렇게 별도 자료구조를 활용하는 습관을 두면 좋을 것 같아요!
또한 이렇게 솔루션 코드를 길게 작성해야 하는 문제일수록 메서드별로 docstring을 달아놓으면 좋을 것 같다는 생각이 들었습니다. 코테에서는 시간이 남으면 꼭 권장드립니다~
| 무슨 알고리즘으로 풀이 할 수 있을까? -> 시뮬레이션(백 트래킹) | ||
|
|
||
| - 시뮬레이션을 위한 함수들을 선언해주었습니다. | ||
| 1. swipe : 한 행 혹은 칼럼의 값 중 0이 아닌 값들을 queue에 넣는 역할을 수행합니다 -> 한 쪽으로 쓸기 |
Contributor
There was a problem hiding this comment.
저는 이걸 matrix 내부에서 while문으로 케이스에 따라 변환해서 구현했는데, 이렇게 구현하면 훨씬 쉽게 구현할 수 있다는 인사이트를 얻어갑니다..! 메모리 조건도 널널한데 이렇게 해볼 생각을 못했네요..! 아주 좋은 아이디어 같습니다.
| board[x][y] = value | ||
|
|
||
|
|
||
| def turn(direct): |
Contributor
There was a problem hiding this comment.
이 부분이 코드 라인 측면에서의 최적화가 굉장히 잘 되었지만 가독성 측면에서 이해하기 어려운 부분이 많았던 것 같습니다. 코테에서는 메서드별로 docstring을 달아놓으시면 혹시 면접때 해당 코드를 참고하게 되더라도 금방 다시 리마인드 하기 편할 것 같아요!
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 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
2048 (Easy)
https://www.acmicpc.net/problem/12100
풀이시간
23:23 ~ 24:14(49분)
풀이 참조 : https://jeongchul.tistory.com/667
문제 조건
1 <= N <=20
시간 복잡도 : O(N^3 * 4 * 4 ^ 5)
O(32,768,000)
접근법
무슨 알고리즘으로 풀이 할 수 있을까? -> 시뮬레이션(백 트래킹)