blob: 23fc45e7aef86573948332969299d7f2bcf0c1c8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include "../../src/cube.h"
#define STRLENMAX 10000
#define MOVESMAX 1000
int main() {
char str[STRLENMAX];
int i, n;
move_t moves[MOVESMAX];
cube_t cube;
fgets(str, STRLENMAX, stdin);
n = readmoves(str, moves);
if (n == -1) {
printf("Error reading moves\n");
return 1;
}
fgets(str, STRLENMAX, stdin);
cube = readcube(str);
for (i = 0; i < n; i++)
cube = move(cube, moves[i]);
if (cube.e == errorcube.e && cube.c == errorcube.c) {
printf("Error moving cube\n");
} else if (!isconsistent(cube)) {
printf("Moved cube is inconsistent\n");
} else {
writecube(cube, str);
printf("%s\n", str);
}
return 0;
}
|