Skip to content

Instantly share code, notes, and snippets.

@stenehall
Created July 8, 2013 16:23
Show Gist options
  • Save stenehall/5950274 to your computer and use it in GitHub Desktop.
Save stenehall/5950274 to your computer and use it in GitHub Desktop.
// 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