Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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