Created
May 8, 2019 07:51
-
-
Save dstyle0210/3ac9de61abf6a9141bcb82eff9a4fe63 to your computer and use it in GitHub Desktop.
프로그래머스 : 하노이의 탑
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
| 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