Skip to content

Instantly share code, notes, and snippets.

@dmjio
Created October 10, 2011 21:23
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 dmjio/1276586 to your computer and use it in GitHub Desktop.
Save dmjio/1276586 to your computer and use it in GitHub Desktop.
Towers of Hanoi in Javascript
var hanoi = function(disc,src,aux,dst) {
if (disc > 0) {
hanoi(disc - 1, src,dst,aux);
document.write('Move disc ' + disc + ' from ' + src + ' to ' + dst);
hanoi(disc-1,aux,src,dst);
}
}
hanoi(3, 'src','aux','dst');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment