works up to and including 7

master
Matthew Huntington 3 years ago
parent 75a5a1be00
commit 782bb1d9bc

@ -39,7 +39,7 @@ const breakDown = (node)=>{
return node;
}
const tree = breakDown({value:7});
const tree = breakDown({value:9});
console.dir(tree, {depth:null});
@ -49,15 +49,19 @@ const getLeaves = (node)=>{
}
let twoPathResult = [];
const twoPathLeftValue = getLeaves(node.twoPath.left);
const twoPathRightValue = getLeaves(node.twoPath.right);
const twoPathLeftValue = getLeaves(node.twoPath.left);//2
const twoPathRightValue = getLeaves(node.twoPath.right);//[2,2]
if(Number.isInteger(twoPathRightValue)){
twoPathResult[0] = twoPathLeftValue;
twoPathResult[1] = twoPathRightValue;
} else {
twoPathRightValue[0].unshift(twoPathLeftValue)
twoPathRightValue[1].unshift(twoPathLeftValue);
twoPathResult = twoPathRightValue;
if(Number.isInteger(twoPathRightValue[0])){
twoPathRightValue.unshift(twoPathLeftValue);
} else {
twoPathRightValue[0].unshift(twoPathLeftValue)
twoPathRightValue[1].unshift(twoPathLeftValue);
}
twoPathResult = twoPathRightValue;
}
let threePathResult = [];

Loading…
Cancel
Save