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
@@ -34,6 +34,23 @@ int128_t gcd3(int128_t a, int128_t b, int128_t c);
|
||||
*/
|
||||
int128_t gcd2(int128_t a, int128_t b);
|
||||
|
||||
/**
|
||||
* @brief Returns the minimum of 3 128 bit integers
|
||||
* @param a The first integer
|
||||
* @param b The second integer
|
||||
* @param c The third integer
|
||||
* @return The minimum of the three integers
|
||||
*/
|
||||
int128_t min3(int128_t a, int128_t b, int128_t c);
|
||||
|
||||
/**
|
||||
* @brief Returns the minimum of 2 128 bit integers
|
||||
* @param a The first integer
|
||||
* @param b The second integer
|
||||
* @return The minimum of the two integers
|
||||
*/
|
||||
int128_t min2(int128_t a, int128_t b);
|
||||
|
||||
/**
|
||||
* @brief Returns the absolute value of a 128 bit integer
|
||||
* @param x The integer to get the absolute value of
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#ifndef BFS_H
|
||||
#define BFS_H
|
||||
#ifndef SOLVE_H
|
||||
#define SOLVE_H
|
||||
|
||||
#include "utils.h"
|
||||
|
||||
/**
|
||||
* @brief Runs a BFS to find the minimum moves to reach a triplet with zero
|
||||
* @brief Runs a solver to find the minimum moves to reach a triplet with zero
|
||||
* @param sum Pointer to store the sum of moves for the found solution
|
||||
* @param a0 The initial value of a
|
||||
* @param b0 The initial value of b
|
||||
@@ -12,6 +12,6 @@
|
||||
* @param print_mode The mode for printing the results (1 for full, 2 for minimal)
|
||||
* @return 1 if a solution is found, 0 otherwise
|
||||
*/
|
||||
bool run_bfs(int128_t* sum, int128_t a0, int128_t b0, int128_t c0, int print_mode);
|
||||
bool solve(int128_t* sum, int128_t a0, int128_t b0, int128_t c0, int print_mode);
|
||||
|
||||
#endif /* BFS_H */
|
||||
#endif /* SOLVE_H */
|
||||
Reference in new issue
Block a user