Created
July 8, 2013 16:23
-
-
Save stenehall/5950274 to your computer and use it in GitHub Desktop.
Solve Tower of Hanoi (http://www.dynamicdrive.com/dynamicindex12/towerhanoi.htm)
This file contains hidden or 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
// Tower of Hanoi | |
// http://www.dynamicdrive.com/dynamicindex12/towerhanoi.htm | |
var Hanoi = function Hanoi() { | |
}; | |
Hanoi.prototype.solve = function solve(disks) { | |
// Solve it! | |
} | |
// example usage | |
var hanoi = new Hanoi(); | |
hanoi.solve(3); //=> 1 to 3, 1 to 2, 3 to 2, 1 to 3, 2 to 1, 2 to 3, 1 to 3 | |
var hanoi = new Hanoi(); | |
hanoi.solve(4); //=> 1 to 2, ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment