hanoi
v0.0.2
Published
Tower of Hanoi algorithm for finding the smallest number of steps to move the stack.
Maintainers
Readme
hanoi
Tower of Hanoi algorithm for finding the smallest number of steps to move the stack.
The Towers of Hanoi is a mathematical puzzle whose solution illustrates recursion. There are three pegs which can hold stacks of disks of different diameters. A larger disk may never be stacked on top of a smaller. Starting with n disks on one peg, they must be moved to another peg one at a time. — Wikipedia
Install
npm install hanoibower install hanoiUsage
const hanoi = require('hanoi');
console.log(hanoi(0)); // 0
console.log(hanoi(1)); // 1
console.log(hanoi(2)); // 3
console.log(hanoi(3)); // 7
console.log(hanoi(4)); // 15
console.log(hanoi(5)); // 31
console.log(hanoi(6)); // 63
console.log(hanoi(7)); // 127
console.log(hanoi(8)); // 255
console.log(hanoi(9)); // 511Test
npm testLicense
MIT

