From b0053277e385bee23336d1fe6b69a12f49f9172f Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Tue, 1 Apr 2025 09:33:26 +0200 Subject: simplified allowedmoves logic --- test/080_allowedmoves/allowedmoves_tests.c | 31 ++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 test/080_allowedmoves/allowedmoves_tests.c (limited to 'test/080_allowedmoves/allowedmoves_tests.c') diff --git a/test/080_allowedmoves/allowedmoves_tests.c b/test/080_allowedmoves/allowedmoves_tests.c new file mode 100644 index 0000000..aa6bda7 --- /dev/null +++ b/test/080_allowedmoves/allowedmoves_tests.c @@ -0,0 +1,31 @@ +#include "../test.h" + +bool allowedmoves(size_t n, const uint8_t [n]); + +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; + + 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; + } + + printf("%s\n", allowedmoves(n, m) ? "true" : "false"); +} -- cgit v1.3