Renaming bfs to solver. Adding fclose so the file doesn't remain open after use. Finally creating min2 and min3 functions.
This commit is contained in:
5 files changed
+48
-14
No files matched your search
+5
-4
@@ -3,7 +3,7 @@
|
||||
#include "hash.h"
|
||||
#include "node.h"
|
||||
#include "queue.h"
|
||||
#include "bfs.h"
|
||||
#include "solve.h"
|
||||
#include "io.h"
|
||||
|
||||
#include <stdio.h>
|
||||
@@ -31,7 +31,7 @@ bool is_new_root(int128_t a, int128_t b, int128_t c) {
|
||||
}
|
||||
|
||||
GlobalEntry* e = malloc(sizeof(GlobalEntry));
|
||||
if (!e) return true; /* Fallback to running BFS if malloc fails */
|
||||
if (!e) return true; /* Fallback to running the solver if malloc fails */
|
||||
e->a = a; e->b = b; e->c = c;
|
||||
e->next = global_root_table[h];
|
||||
global_root_table[h] = e;
|
||||
@@ -123,7 +123,7 @@ int main() {
|
||||
int128_t greater = b >= c ? b : c;
|
||||
LIMIT = a >= greater ? a * greater : b * c;
|
||||
|
||||
run_bfs(&sum, a, b, c, print_mode);
|
||||
solve(&sum, a, b, c, print_mode);
|
||||
} else if (mode == 2) {
|
||||
clear_global_table(); /* Reset unique root tracker */
|
||||
int32_t p = 7;
|
||||
@@ -147,12 +147,13 @@ int main() {
|
||||
if (is_new_root(ra, rb, rc)) {
|
||||
int128_t greater = rb >= rc ? rb : rc;
|
||||
LIMIT = ra >= greater ? ra * greater / 2 : rb * rc / 2;
|
||||
run_bfs(&sum, ra, rb, rc, print_mode);
|
||||
solve(&sum, ra, rb, rc, print_mode);
|
||||
}
|
||||
}
|
||||
|
||||
printf("Total sum is: ");
|
||||
print_int128(sum); printf("\n");
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
queue_destroy();
|
||||
|
||||
Reference in new issue
Block a user