Created
January 30, 2012 01:46
-
-
Save alkos333/1701874 to your computer and use it in GitHub Desktop.
Towers of Hanoi (Recursive)
This file contains 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
#!/usr/bin/env node | |
var hanoi = function(disc, src, tmp, dst){ | |
if(disc > 0){ | |
hanoi(disc - 1, src, dst, tmp); | |
console.log(disc + " " + src + "->" + dst); | |
hanoi(disc - 1, tmp, src, dst); | |
} | |
} | |
hanoi(process.argv[2], '1', '3', '2'); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment