Exemplo n.º 1
0
def read_and_solve_case(input, out=None, best=False, first=False):
	parser = Parser(input)
	solver = Solver(0, [], first)
	if out:
		output_file = open(out, 'w')
	for i in range(parser.c):
		solver.customers = parser.read_next_case()
		solver.length = parser.current_n
		solver.compute_solutions()
		if best:
			sol = solver.get_optimal_solution()
		else:
			sol = solver.get_random_solution()
		if sol != "IMPOSSIBLE":
			solution_string = "Case #" + str(i + 1) + ": " + " ".join(sol)
		else:
			solution_string = "Case #" + str(i + 1) + ": " + sol
		print solution_string
		if out:
			output_file.write(solution_string + '\n')
	if out:
		output_file.close()