https://programmers.co.kr/learn/courses/30/lessons/12985
1. 성공
function solution(n,a,b){
var answer = 0;
var numA = a;
var numB = b;
while(numA!=numB){
numA = Math.ceil(numA /2);
numB = Math.ceil(numB /2);
answer = answer + 1;
}
return answer
}
2. 실패 - 7, 9, 27, 33번 테스트 실패
// 실패 케이스 잘 모르겠음..
function solution(n,a,b){
var answer = 0;
var numA = a;
var numB = b;
while(Math.abs(numA-numB)!==1){
numA = Math.ceil(numA /2);
numB = Math.ceil(numB /2);
answer = answer + 1;
}
answer = answer+1;
return answer
return answer
}
Math.abs(numA-numB)!==1는 왜 안되지?