Skip to content

Instantly share code, notes, and snippets.

@dstyle0210
Created May 8, 2019 07:51
Show Gist options
  • Select an option

  • Save dstyle0210/3ac9de61abf6a9141bcb82eff9a4fe63 to your computer and use it in GitHub Desktop.

Select an option

Save dstyle0210/3ac9de61abf6a9141bcb82eff9a4fe63 to your computer and use it in GitHub Desktop.
프로그래머스 : 하노이의 탑
function solution(n) {
var answer = [];
var hanoi = function(ring,from,by,to){
if(ring==1){
answer.push([from,to]);
}else{
hanoi(ring-1,from,to,by);
answer.push([from,to]);
hanoi(ring-1,by,from,to);
};
};
hanoi(n,1,2,3);
return answer;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment