aboutsummaryrefslogtreecommitdiff
path: root/test/130_allowednext_h48/allowednext_h48_tests.c
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2024-09-03 21:52:16 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2024-09-03 21:52:16 +0200
commitc9e2d6466e42d6b779ac9ffa7c5ee9a9c7558df8 (patch)
treef4f569fcbd4d6704fb5dd44892911ce808f03332 /test/130_allowednext_h48/allowednext_h48_tests.c
parentff4bde84872ec0b93f0f097f5a56bd5e7cbb0311 (diff)
downloadnissy-core-c9e2d6466e42d6b779ac9ffa7c5ee9a9c7558df8.tar.gz
nissy-core-c9e2d6466e42d6b779ac9ffa7c5ee9a9c7558df8.zip
Moved stuff around
Diffstat (limited to 'test/130_allowednext_h48/allowednext_h48_tests.c')
-rw-r--r--test/130_allowednext_h48/allowednext_h48_tests.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/test/130_allowednext_h48/allowednext_h48_tests.c b/test/130_allowednext_h48/allowednext_h48_tests.c
new file mode 100644
index 0000000..64ded35
--- /dev/null
+++ b/test/130_allowednext_h48/allowednext_h48_tests.c
@@ -0,0 +1,38 @@
1#include "../test.h"
2
3uint32_t allowednextmove_h48(uint8_t *, uint8_t, uint32_t);
4
5static char *moves[] = {
6 "U", "U2", "U'",
7 "D", "D2", "D'",
8 "R", "R2", "R'",
9 "L", "L2", "L'",
10 "F", "F2", "F'",
11 "B", "B2", "B'",
12};
13
14void run(void) {
15 char movestr[STRLENMAX];
16 uint8_t m[100];
17 int n, i, j, bound;
18
19 fgets(movestr, STRLENMAX, stdin);
20 bound = atoi(movestr);
21
22 fgets(movestr, STRLENMAX, stdin);
23 n = atoi(movestr);
24
25 for (i = 0; i < n; i++) {
26 fgets(movestr, STRLENMAX, stdin);
27 movestr[strcspn(movestr, "\n")] = 0;
28 for (j = 0; j < 18; j++)
29 if (!strcmp(movestr, moves[j]))
30 m[i] = j;
31 }
32
33 fprintf(stderr, "Last two: %s, %s\n",
34 n > 1 ? moves[m[n-2]] : "-",
35 n > 0 ? moves[m[n-1]] : "-");
36 uint32_t allowed = allowednextmove_h48(m, n, bound);
37 printf("0x%05X\n", allowed);
38}

Generated with cgit - Back to sebastiano.tronto.net