Esempio n. 1
0
static void convertPath(btstring_t *data, int32_t x, int32_t y)
{
	uint32_t		index;
	uint32_t		i;
	int32_t			saveX, saveY;
	uint32_t		numPaths;

	index	= xy2index(x, y);
	data->buf[index] = 0xff;

	while (countPaths(data, x, y) == 1) {
		move(data, &x, &y);
		data->buf[xy2index(x, y)] = 0xff;
	}

	if (!countPaths(data, x, y)) {
		return;
	}

	saveX	= x;
	saveY	= y;
	numPaths = countPaths(data, x, y);
	for (i = 0; i < numPaths; i++) {
		move(data, &x, &y);
		convertPath(data, x, y);
		x = saveX;
		y = saveY;
	}
}
Esempio n. 2
0
int main(int argc, char **argv) {

    if (argc > 2 || (argc == 2 && strcmp(argv[1], "print"))) {
        printf(
                "I expect no command line argument or \"print\" as unique command line argument.\n");
        return EXIT_FAILURE;
    }
    if (!get_input()) {
        printf("Incorrect input.\n");
        return EXIT_FAILURE;
    }
    convertMaze();
    if (argc == 2) {
        drawMaze();
        return EXIT_SUCCESS;
    }

    countGates();
    countWalls();
    countInAccAreas();
    countAccAreas();
    countCuldesacs();
    countPaths();
    outputResult();

    return EXIT_SUCCESS;
}
Esempio n. 3
0
int countPaths(int (*target)[COL], int n, int row, int col)
{
	int innerCount = 0;

	if(n == 1)
		return 2;

	if(target[row][col+1] == 0)
		innerCount += countPaths(target, n-1, row, col+1);

	if(target[row+1][col] == 0)
		innerCount +=countPaths(target, n-1, row+1, col);
	
	
	return innerCount;
}
Esempio n. 4
0
int main(void)
{
	int grid[ROW][COL] = {0};
	int n = ROW;
	int pathNum = countPaths(grid, n, 0, 0);
	printf("pathNum = %d \n", pathNum);

	return 0;
}