From c4f64cf2556c0f8597e1fbc19d7c664b8da94612 Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Fri, 11 Oct 2024 19:24:15 +0200 Subject: Added buffer sizes in API args --- tools/300_solve_small/solve_small.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'tools/300_solve_small') diff --git a/tools/300_solve_small/solve_small.c b/tools/300_solve_small/solve_small.c index ade949a..5400436 100644 --- a/tools/300_solve_small/solve_small.c +++ b/tools/300_solve_small/solve_small.c @@ -1,6 +1,9 @@ #include "../tool.h" +#define SOL_BUFFER_LEN 1000 + const char *solver = "h48h0k4"; +int64_t size = 0; char *buf; char *scrambles[] = { @@ -14,25 +17,22 @@ char *scrambles[] = { void run(void) { int i; int64_t n; - char sol[100], cube[22]; + char sol[SOL_BUFFER_LEN], cube[22]; printf("Solved the following scrambles:\n\n"); for (i = 0; scrambles[i] != NULL; i++) { printf("%d. %s\n", i+1, scrambles[i]); - fprintf(stderr, "Solving scramble %s\n", scrambles[i]); + printf("Solving scramble %s\n", scrambles[i]); if (nissy_frommoves(scrambles[i], cube) == -1) { - fprintf(stderr, "Invalid scramble\n"); - printf("Invalid\n"); + printf("Invalid scramble\n"); continue; } - n = nissy_solve( - cube, solver, "", 0, 20, 1, -1, buf, sol); - if (n == 0) { - printf("No solution\n"); - fprintf(stderr, "No solution found\n"); - } else { + n = nissy_solve(cube, solver, NISSY_NISSFLAG_NORMAL, + 0, 20, 1, -1, size, buf, SOL_BUFFER_LEN, sol); + if (n == 0) + printf("No solution found\n"); + else printf("Solutions:\n%s\n", sol); - } } } @@ -46,6 +46,8 @@ int main(void) { if (getdata(solver, &buf, filename) != 0) return 1; + size = nissy_datasize(solver); + timerun(run); free(buf); -- cgit v1.3