diff options
Diffstat (limited to 'test/082_allowednext_h48/allowednext_h48_tests.c')
| -rw-r--r-- | test/082_allowednext_h48/allowednext_h48_tests.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/test/082_allowednext_h48/allowednext_h48_tests.c b/test/082_allowednext_h48/allowednext_h48_tests.c new file mode 100644 index 0000000..4cee695 --- /dev/null +++ b/test/082_allowednext_h48/allowednext_h48_tests.c | |||
| @@ -0,0 +1,38 @@ | |||
| 1 | #include "../test.h" | ||
| 2 | |||
| 3 | uint32_t allowednextmoveH48(uint8_t *, uint8_t, uint32_t); | ||
| 4 | |||
| 5 | static 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 | |||
| 14 | void 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 = allowednextmoveH48(m, n, bound); | ||
| 37 | printf("0x%05X\n", allowed); | ||
| 38 | } | ||
