Esempio n. 1
0
int main(int argc, char** argv) {

	FILE* fproblem = fopen(argv[1], "r");
	FILE* fsolution = fopen(argv[2], "r");

	if(fproblem == 0 || fsolution == 0) {
		printf("Error opening file\n");
		exit(1);
	}
	
	problem* prob = loadProblem(fproblem, fsolution);

	int* options = malloc(prob->size * sizeof(int));

	// Fill out the numbers which must appear in each house for this size
	for (int i = 1; i <= prob->size; ++i) {
		options[i - 1] = i;
	}

	if (!isValidSolution(prob, sqrt(prob->size), options)) errInvalidSol();
	else if (isComplete(prob)) printf("SOLVED\n");
	else printf("INCOMPLETE\n");
	
	freeProblem(prob);
}
size_t CRowSolution<T>::setSolutionFlags(char *buffer, size_t lenBuf, size_t solIdx) const
{
	memset(buffer, ' ', lenBuf);
	const uchar *pCanonFlags = solutionPerm()->canonFlags();
	if (!pCanonFlags)
		return solIdx += lenBuf / 2;

	for (size_t i = 0; i < lenBuf; i += 2, solIdx++) {
		if (*(pCanonFlags + solIdx) == 1)
			buffer[i + 1] = '!';
		else
		if (!isValidSolution(solIdx))
			buffer[i + 1] = '-';
	}

	return solIdx;
}