From 147b0c3c4615c32478a4923242909b8ae5a30d03 Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Sun, 23 Nov 2025 16:16:31 +0100 Subject: Fix duplicate solutions, overflow in maxsols and improve symmetry reduction for H48. This commit fixes two bugs: - A bug that caused duplicates solutions for symmetric scrambles. - An overflow in the maxsols parameter for the H48 solver, which caused it to find much fewer solutions than existed. Moreover, the H48 solvers has been improved by reducing by symmetry not only from the starting position, but also up to the first 4 moves. --- test/140_appendsolution/appendsolution_tests.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'test/140_appendsolution/appendsolution_tests.c') diff --git a/test/140_appendsolution/appendsolution_tests.c b/test/140_appendsolution/appendsolution_tests.c index d4c2a1f..f9620ab 100644 --- a/test/140_appendsolution/appendsolution_tests.c +++ b/test/140_appendsolution/appendsolution_tests.c @@ -3,8 +3,10 @@ Input format for appendsolution tests: moves on normal (with NISS notation) unniss flag (0=false, 1=true) -number of transformations -transformations, one per line +n = maximum number of moves for transformations + 1 (at most 20) +n times the following: + number of transformations + transformations, one per line the orientation of the cube, as a number from 0 to 23 See below for the output format. @@ -18,11 +20,13 @@ int64_t readmoves(const char *, size_t n, size_t m, void solution_moves_reset(solution_moves_t [static 1]); bool solution_list_init(solution_list_t [static 1], size_t n, char [n]); int64_t appendsolution(const solution_moves_t [static 1], - const solution_settings_t [static 1], solution_list_t [static 1]); + size_t, const uint64_t *, const solution_settings_t [static 1], + solution_list_t [static 1]); void run(void) { - int i, ntrans; + int i, j, nnt, ntrans; int64_t tot; + uint64_t tmask[20]; size_t nm, np; char str[STRLENMAX], buf[STRLENMAX]; solution_moves_t moves; @@ -32,7 +36,6 @@ void run(void) { solution_moves_reset(&moves); solution_list_init(&list, STRLENMAX, buf); settings = (solution_settings_t) { - .tmask = UINT64_C(0), .unniss = false, .maxmoves = 20, .maxsolutions = 100, @@ -49,16 +52,21 @@ void run(void) { moves.npremoves = np; fgets(str, STRLENMAX, stdin); settings.unniss = (bool)atoi(str); + fgets(str, STRLENMAX, stdin); - ntrans = atoi(str); - for (i = 0; i < ntrans; i++) { + nnt = atoi(str); + for (j = 0; j < nnt; j++) { fgets(str, STRLENMAX, stdin); - settings.tmask |= UINT64_C(1) << (uint64_t)readtrans(str); + ntrans = atoi(str); + for (i = 0; i < ntrans; i++) { + fgets(str, STRLENMAX, stdin); + tmask[j] |= UINT64_C(1) << (uint64_t)readtrans(str); + } } fgets(str, STRLENMAX, stdin); settings.orientation = atoi(str); - appendsolution(&moves, &settings, &list); + appendsolution(&moves, nnt, tmask, &settings, &list); printf("%s", list.buf); printf("Number of solutions: %" PRIu64 "\n", list.nsols); -- cgit v1.3