aboutsummaryrefslogtreecommitdiff
path: root/test/140_appendsolution/appendsolution_tests.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/140_appendsolution/appendsolution_tests.c')
-rw-r--r--test/140_appendsolution/appendsolution_tests.c26
1 files changed, 17 insertions, 9 deletions
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:
3 3
4moves on normal (with NISS notation) 4moves on normal (with NISS notation)
5unniss flag (0=false, 1=true) 5unniss flag (0=false, 1=true)
6number of transformations 6n = maximum number of moves for transformations + 1 (at most 20)
7transformations, one per line 7n times the following:
8 number of transformations
9 transformations, one per line
8the orientation of the cube, as a number from 0 to 23 10the orientation of the cube, as a number from 0 to 23
9 11
10See below for the output format. 12See below for the output format.
@@ -18,11 +20,13 @@ int64_t readmoves(const char *, size_t n, size_t m,
18void solution_moves_reset(solution_moves_t [static 1]); 20void solution_moves_reset(solution_moves_t [static 1]);
19bool solution_list_init(solution_list_t [static 1], size_t n, char [n]); 21bool solution_list_init(solution_list_t [static 1], size_t n, char [n]);
20int64_t appendsolution(const solution_moves_t [static 1], 22int64_t appendsolution(const solution_moves_t [static 1],
21 const solution_settings_t [static 1], solution_list_t [static 1]); 23 size_t, const uint64_t *, const solution_settings_t [static 1],
24 solution_list_t [static 1]);
22 25
23void run(void) { 26void run(void) {
24 int i, ntrans; 27 int i, j, nnt, ntrans;
25 int64_t tot; 28 int64_t tot;
29 uint64_t tmask[20];
26 size_t nm, np; 30 size_t nm, np;
27 char str[STRLENMAX], buf[STRLENMAX]; 31 char str[STRLENMAX], buf[STRLENMAX];
28 solution_moves_t moves; 32 solution_moves_t moves;
@@ -32,7 +36,6 @@ void run(void) {
32 solution_moves_reset(&moves); 36 solution_moves_reset(&moves);
33 solution_list_init(&list, STRLENMAX, buf); 37 solution_list_init(&list, STRLENMAX, buf);
34 settings = (solution_settings_t) { 38 settings = (solution_settings_t) {
35 .tmask = UINT64_C(0),
36 .unniss = false, 39 .unniss = false,
37 .maxmoves = 20, 40 .maxmoves = 20,
38 .maxsolutions = 100, 41 .maxsolutions = 100,
@@ -49,16 +52,21 @@ void run(void) {
49 moves.npremoves = np; 52 moves.npremoves = np;
50 fgets(str, STRLENMAX, stdin); 53 fgets(str, STRLENMAX, stdin);
51 settings.unniss = (bool)atoi(str); 54 settings.unniss = (bool)atoi(str);
55
52 fgets(str, STRLENMAX, stdin); 56 fgets(str, STRLENMAX, stdin);
53 ntrans = atoi(str); 57 nnt = atoi(str);
54 for (i = 0; i < ntrans; i++) { 58 for (j = 0; j < nnt; j++) {
55 fgets(str, STRLENMAX, stdin); 59 fgets(str, STRLENMAX, stdin);
56 settings.tmask |= UINT64_C(1) << (uint64_t)readtrans(str); 60 ntrans = atoi(str);
61 for (i = 0; i < ntrans; i++) {
62 fgets(str, STRLENMAX, stdin);
63 tmask[j] |= UINT64_C(1) << (uint64_t)readtrans(str);
64 }
57 } 65 }
58 fgets(str, STRLENMAX, stdin); 66 fgets(str, STRLENMAX, stdin);
59 settings.orientation = atoi(str); 67 settings.orientation = atoi(str);
60 68
61 appendsolution(&moves, &settings, &list); 69 appendsolution(&moves, nnt, tmask, &settings, &list);
62 70
63 printf("%s", list.buf); 71 printf("%s", list.buf);
64 printf("Number of solutions: %" PRIu64 "\n", list.nsols); 72 printf("Number of solutions: %" PRIu64 "\n", list.nsols);

Generated with cgit - Back to sebastiano.tronto.net