aboutsummaryrefslogtreecommitdiff
path: root/test/090_allowedmoves/allowedmoves_tests.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/090_allowedmoves/allowedmoves_tests.c')
-rw-r--r--test/090_allowedmoves/allowedmoves_tests.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/090_allowedmoves/allowedmoves_tests.c b/test/090_allowedmoves/allowedmoves_tests.c
new file mode 100644
index 0000000..aa6bda7
--- /dev/null
+++ b/test/090_allowedmoves/allowedmoves_tests.c
@@ -0,0 +1,31 @@
1#include "../test.h"
2
3bool allowedmoves(size_t n, const uint8_t [n]);
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;
18
19 fgets(movestr, STRLENMAX, stdin);
20 n = atoi(movestr);
21
22 for (i = 0; i < n; i++) {
23 fgets(movestr, STRLENMAX, stdin);
24 movestr[strcspn(movestr, "\n")] = 0;
25 for (j = 0; j < 18; j++)
26 if (!strcmp(movestr, moves[j]))
27 m[i] = j;
28 }
29
30 printf("%s\n", allowedmoves(n, m) ? "true" : "false");
31}

Generated with cgit - Back to sebastiano.tronto.net