aboutsummaryrefslogtreecommitdiff
path: root/test/031_premove/premove_tests.c
blob: 10bed9255d78315c6537059533ccac787443bf0f (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
#include "../test.h"

uint8_t readmove(char);
uint8_t readmodifier(char);
cube_t premove(cube_t, uint8_t);

void run(void) {
	char movestr[STRLENMAX], cubestr[STRLENMAX];
	uint8_t move;
	oriented_cube_t cube;

	fgets(movestr, STRLENMAX, stdin);
	move = readmove(movestr[0]) + readmodifier(movestr[1]);
	fgets(cubestr, STRLENMAX, stdin);
	cube = readcube(cubestr);

	cube.cube = premove(cube.cube, move);

	if (iserror(cube)) {
		printf("Error moving cube\n");
	} else if (!issolvable(cube)) {
		printf("Moved cube is not solvable\n");
	} else {
		writecube(cube, NISSY_SIZE_CUBE, cubestr);
		printf("%s\n", cubestr);
	}
}

Generated with cgit - Back to sebastiano.tronto.net