We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 74278c0 commit d06603dCopy full SHA for d06603d
level-2/예상-대진표.js
@@ -0,0 +1,15 @@
1
+//https://github.com/codeisneverodd/programmers-coding-test
2
+//완벽한 정답이 아닙니다.
3
+//정답 1 - codeisneverodd
4
+
5
+function solution(n, a, b) {
6
+ let currentRound = 1;
7
+ const myNextNumber = (num) => Math.floor((num + 1) / 2)//내가 이긴경우 다음으로 가지게 될 번호
8
+ while (a !== b) { // a의 다음 번호가 b의 다음번호와 같아지면 끝난다.
9
+ if (myNextNumber(a) === myNextNumber(b)) break
10
+ a = myNextNumber(a)
11
+ b = myNextNumber(b)
12
+ currentRound++
13
+ }
14
+ return currentRound
15
+}
0 commit comments