/* ----------------------------------------------------
汉诺塔题解
----------------------------------------------------- */
var Stack = require("ss-stack");
var towerOfHanoi = function(n, from, help, to) {
if (n > 0) {
towerOfHanoi(n-1, from, to, help);
to.push(from.pop());
console.log('----------------');
console.log(`from: ${from.stack.toArray()}`);
console.log(`help: ${help.stack.toArray()}`);
console.log(`to: ${to.stack.toArray()}`);
towerOfHanoi(n-1, help, from, to);
}
}
var a = new Stack(),
b = new Stack(),
c = new Stack(),
n = 4;
for(let i = n; i > 0; i--) {
a.push(i);
}
// test
towerOfHanoi(a.length, a, b, c);