Last active
August 29, 2015 14:27
-
-
Save RUPOJS/f0f72758324e7b99c1e1 to your computer and use it in GitHub Desktop.
Tower of Hanoi implementation in JavaScript using recursion
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
var write = function(string) { | |
document.write(string); | |
} | |
var i = 0; | |
var hanoi = function(disc,src,aux,dst) { | |
if (disc > 0) { | |
hanoi(disc - 1,src,dst,aux); | |
write("Move disc " + disc + " from " + src + " to " + dst + "<br />"); | |
hanoi(disc - 1,aux,src,dst); | |
} | |
}; | |
hanoi(3,"src","aux","dst"); | |
// for more, please see - http://www.geeksforgeeks.org/iterative-tower-of-hanoi/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment