Code coverage report for lib/algorithms/3-stacks/hanoi.js

Statements: 100% (11 / 11)      Branches: 100% (2 / 2)      Functions: 100% (2 / 2)      Lines: 100% (10 / 10)      Ignored: none     

All files » lib/algorithms/3-stacks/ » hanoi.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19    1   9 9 9   1   75   33 33 33     9  
//3.3? Solve the tower of hanoi problem
 
module.exports = function(source, helper, target) {
 
    source.name = "source";
    helper.name = "helper";
    target.name = "target";
 
    function moveDisks(n, source, helper, target) {
 
        if (n <= 0 ) return;
 
        moveDisks(n-1, source, target, helper );
        target.push(source.pop());
        moveDisks(n-1, helper, source, target );
    }
 
    moveDisks(source.length, source, helper, target);
}