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

Loading…
Cancel
Save