//汉塔问题
//返回多少步可以将圆盘移动到目标柱子上
// 1.将起始柱上的 n-1 个圆盘移动到辅助柱上;
// 2.将起始柱上遗留的 1 个圆盘移动到目标柱上;
// 3.将辅助柱上的所有圆盘移动到目标柱上。
const hantaFn = (number,source,tarfet,auxill)=>{
let count = 0
function hantaOI (num,sou,tar,aux){
if(num===1){
count++
console.log(`第${count}次从${sou}移动到${tar}`)
}else{
hantaOI(num-1,sou,aux,tar)
count++
console.log(`第${count}次从${sou}移动到${tar}`)
hantaOI(num-1,aux,tar,sou)
}
}
hantaOI(number,source,tarfet,auxill)
return count
}
console.log(hantaFn(3, 'A', 'B', 'C'))