Merged
Conversation
Implement solution for predicting matchups in a tournament.
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.
🧷 문제 링크
https://school.programmers.co.kr/learn/courses/30/lessons/12985
🧭 풀이 시간
10분
👀 체감 난이도
✏️ 문제 설명
N명이 토너먼트를 함.
1,2번중 이긴사람이 1번
3,4번중 이긴사람이 2번
...
위 과정을 반복하게 됨.
임의의 A와 B가 있음. 이 둘이 계속 승리할때, 몇번째 라운드에서 만나게 되는지 출력.
🔍 풀이 방법
한 라운드에서 이긴 사람이 배정받는 다음 번호는 2로 나눈 몫과 나머지를 더한 꼴임.
따라서 이걸로 지속적으로 업데이트 해주고 수가 같거나 둘의 차이가 1이상 나는 경우에는 반복함.
⏳ 회고
종료 조건을 생각하는게 까다로웠다.
그냥 1차이 나면 종료하게끔 할라했는데, 2와 3은 서로 다른 라운드에서 진행하기에 한번 더 값 업데이트를 해야했다.
마지막에 예외처리해도 되지만, 뭔가 깔끔하게 업데이트하는 방식은 몫과 나머지를 더하는 거였던 것 같다.