Skip to content

Instantly share code, notes, and snippets.

@alkos333
Created January 30, 2012 01:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alkos333/1701874 to your computer and use it in GitHub Desktop.
Save alkos333/1701874 to your computer and use it in GitHub Desktop.
Towers of Hanoi (Recursive)
#!/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