allowednext_h48_tests.c (794B)
1 #include "../test.h" 2 3 uint32_t allowednextmove_h48(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 = allowednextmove_h48(m, n, bound); 37 printf("0x%05X\n", allowed); 38 }