binary tree compare: multiple solutions solver
This commit is contained in:
28
best.c
28
best.c
@@ -61,14 +61,28 @@ int check_best(res, nops, node, values, ops)
|
||||
nbests=0;
|
||||
found=1;
|
||||
//return 1;
|
||||
} /*else if (diff == bestdiff && nops == bestops) {
|
||||
# ifdef DEBUG_BEST
|
||||
printf("NEW BEST SOLUTION (%d): res=%d diff=%d nops=%d\n", nbests+1, res, diff, nops);
|
||||
print_node(node, TREE_TOP, 0, 0);
|
||||
# endif
|
||||
} else if (diff == bestdiff && nops == bestops) {
|
||||
// if (nbests) {
|
||||
found=2;
|
||||
}*/
|
||||
if (found==1) {
|
||||
for (i=0; i<nbests; ++i) {
|
||||
if (compare_nodes(node, bests[i].root, 0)) {
|
||||
found=0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
# ifdef DEBUG_BEST
|
||||
if (found==2) {
|
||||
printf("new diff solution (%d): res=%d diff=%d nops=%d\n",
|
||||
nbests+1, res, diff, nops);
|
||||
print_node(node, TREE_TOP, 0, 0);
|
||||
} else {
|
||||
printf("skipping duplicate solution (%d): res=%d diff=%d nops=%d\n",
|
||||
nbests+1, res, diff, nops);
|
||||
}
|
||||
# endif
|
||||
}
|
||||
//}
|
||||
if (found) {
|
||||
set_timer(&(bests[nbests].timer));
|
||||
bests[nbests].res=res;
|
||||
bests[nbests].diff=diff;
|
||||
|
Reference in New Issue
Block a user