aboutsummaryrefslogtreecommitdiff
path: root/test/030_move/move_tests.c
blob: b940ecbc6a1db6230222058e85311ef810f3628a (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
#include "../test.h"

cube_t applymoves(cube_t, char *);

int main(void) {
	char movestr[STRLENMAX], cubestr[STRLENMAX];
	int i, n;
	move_t moves[STRLENMAX];
	cube_t cube;

	fgets(movestr, STRLENMAX, stdin);
	fgets(cubestr, STRLENMAX, stdin);
	cube = cube_read("H48", cubestr);

	n = cube_readmoves(movestr, moves);

	if (n == -1)
		printf("Error reading moves!\n");

	for (i = 0; i < n; i++)
		cube = cube_move(cube, moves[i]);

	if (cube_error(cube)) {
		printf("Error moving cube\n");
	} else if (!cube_solvable(cube)) {
		printf("Moved cube is not solvable\n");
	} else {
		cube_write("H48", cube, cubestr);
		printf("%s\n", cubestr);
	}

	return 0;
}

Generated with cgit - Back to sebastiano.tronto.net