코딩테스트
[못풀었다/프로그래머스] 하노이의 탑
_서리__
2023. 6. 3. 11:37
function solution(n){
const answer = [];
const hanoi = (n,from,to,by) =>{
if(n===0) return;
hanoi(n-1,from,by,to)
answer.push([from,to])
hanoi(n-1,by,to,from)
}
hanoi(n,1,3,2)
return answer
}