aboutsummaryrefslogtreecommitdiff
path: root/test/080_allowednext/allowednext_tests.c
blob: 08fe491db3a10d857def3b9ddc57185ccc9c4ac9 (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
#include "../test.h"

bool allowednextmove(size_t n, const uint8_t [n]);

static char *moves[] = {
	"U", "U2", "U'",
	"D", "D2", "D'",
	"R", "R2", "R'",
	"L", "L2", "L'",
	"F", "F2", "F'",
	"B", "B2", "B'",
};

void run(void) {
	char movestr[STRLENMAX];
	uint8_t m[100];
	int n, i, j;

	fgets(movestr, STRLENMAX, stdin);
	n = atoi(movestr);

	for (i = 0; i < n; i++) {
		fgets(movestr, STRLENMAX, stdin);
		movestr[strcspn(movestr, "\n")] = 0;
		for (j = 0; j < 18; j++)
			if (!strcmp(movestr, moves[j]))
				m[i] = j;
	}

	fprintf(stderr, "Last two: %s, %s\nNext: %s\n",
	    n > 2 ? moves[m[n-3]] : "-",
	    n > 1 ? moves[m[n-2]] : "-",
	    n > 0 ? moves[m[n-1]] : "-");
	printf("%s\n", allowednextmove(n, m) ? "true" : "false");
}

Generated with cgit - Back to sebastiano.tronto.net