master
Matthew Huntington 3 years ago
parent 40bcb50cdd
commit 5bc08acc98

@ -49,8 +49,8 @@ const getLeaves = (node)=>{
} }
let twoPathResult = []; let twoPathResult = [];
const twoPathLeftValue = getLeaves(node.twoPath.left);//2 const twoPathLeftValue = getLeaves(node.twoPath.left);
const twoPathRightValue = getLeaves(node.twoPath.right);//[2,2] const twoPathRightValue = getLeaves(node.twoPath.right);
if(Number.isInteger(twoPathRightValue)){ if(Number.isInteger(twoPathRightValue)){
twoPathResult[0] = twoPathLeftValue; twoPathResult[0] = twoPathLeftValue;
twoPathResult[1] = twoPathRightValue; twoPathResult[1] = twoPathRightValue;
@ -66,8 +66,8 @@ const getLeaves = (node)=>{
let threePathResult = []; let threePathResult = [];
if(node.threePath !== undefined){ if(node.threePath !== undefined){
const threePathLeftValue = getLeaves(node.threePath.left); const threePathLeftValue = getLeaves(node.threePath.left);//3
const threePathRightValue = getLeaves(node.threePath.right); const threePathRightValue = getLeaves(node.threePath.right);//[[2,3],[3,2]]
if(Number.isInteger(threePathRightValue)){ if(Number.isInteger(threePathRightValue)){
threePathResult[0] = threePathLeftValue; threePathResult[0] = threePathLeftValue;
threePathResult[1] = threePathRightValue; threePathResult[1] = threePathRightValue;
@ -86,9 +86,19 @@ const getLeaves = (node)=>{
return twoPathResult; return twoPathResult;
} else { } else {
if(Number.isInteger(twoPathResult[0])){ if(Number.isInteger(twoPathResult[0])){
if(Number.isInteger(threePathResult[0])){
return [twoPathResult, threePathResult] return [twoPathResult, threePathResult]
} else { } else {
const result = [twoPathResult];
result.push(threePathResult[0]);
return result;
}
} else {
if(Number.isInteger(threePathResult)){
twoPathResult.push(threePathResult) twoPathResult.push(threePathResult)
} else {
twoPathResult.push(threePathResult[0])
}
return twoPathResult; return twoPathResult;
} }
} }

Loading…
Cancel
Save