move_tests.c (656B)
1 #include "../test.h" 2 3 cube_t applymoves(cube_t, char *); 4 5 int main(void) { 6 char movestr[STRLENMAX], cubestr[STRLENMAX]; 7 int i, n; 8 move_t moves[STRLENMAX]; 9 cube_t cube; 10 11 fgets(movestr, STRLENMAX, stdin); 12 fgets(cubestr, STRLENMAX, stdin); 13 cube = cube_read("H48", cubestr); 14 15 n = cube_readmoves(movestr, moves); 16 17 if (n == -1) 18 printf("Error reading moves!\n"); 19 20 for (i = 0; i < n; i++) 21 cube = cube_move(cube, moves[i]); 22 23 if (cube_error(cube)) { 24 printf("Error moving cube\n"); 25 } else if (!cube_solvable(cube)) { 26 printf("Moved cube is not solvable\n"); 27 } else { 28 cube_write("H48", cube, cubestr); 29 printf("%s\n", cubestr); 30 } 31 32 return 0; 33 }