From c9e2d6466e42d6b779ac9ffa7c5ee9a9c7558df8 Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Tue, 3 Sep 2024 21:52:16 +0200 Subject: Moved stuff around --- test/130_allowednext_h48/allowednext_h48_tests.c | 38 ++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 test/130_allowednext_h48/allowednext_h48_tests.c (limited to 'test/130_allowednext_h48/allowednext_h48_tests.c') 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 @@ +#include "../test.h" + +uint32_t allowednextmove_h48(uint8_t *, uint8_t, uint32_t); + +static char *moves[] = { + "U", "U2", "U'", + "D", "D2", "D'", + "R", "R2", "R'", + "L", "L2", "L'", + "F", "F2", "F'", + "B", "B2", "B'", +}; + +void run(void) { + char movestr[STRLENMAX]; + uint8_t m[100]; + int n, i, j, bound; + + fgets(movestr, STRLENMAX, stdin); + bound = atoi(movestr); + + fgets(movestr, STRLENMAX, stdin); + n = atoi(movestr); + + for (i = 0; i < n; i++) { + fgets(movestr, STRLENMAX, stdin); + movestr[strcspn(movestr, "\n")] = 0; + for (j = 0; j < 18; j++) + if (!strcmp(movestr, moves[j])) + m[i] = j; + } + + fprintf(stderr, "Last two: %s, %s\n", + n > 1 ? moves[m[n-2]] : "-", + n > 0 ? moves[m[n-1]] : "-"); + uint32_t allowed = allowednextmove_h48(m, n, bound); + printf("0x%05X\n", allowed); +} -- cgit v1.3