info.preprocessing_done = time.time() if len(sys.argv) < 4: print("Not enough parameters specified. Quitting...") quit() else: input_info = InputInformation(sys.argv) try: input_file = open(input_info.input_file, "r") output_file = open(input_info.output_file, "w") except: print("Error opening file. Quitting...") quit() file_reader = FileReader(input_file) file_writer = FileWriter(output_file) N, P, Q, = file_reader.get_params() board = file_reader.get_board() sudoku_board = SudokuSolver(N, P, Q, board, input_info.tokens) info.search_start = time.time() sudoku_board.start_time = info.search_start sudoku_board.time_out_limit = float(input_info.timeout_limit) if False: sudoku_board.heap_test() else: if input_info.tokens["LCV"]: solved_board = sudoku_board.solve_board_value_heap(False) else: solved_board = sudoku_board.solve_board_heap(False) info.search_done = time.time()
from src.file_reader import FileReader from src.sudoku_generator import SudokuBoardGenerator from src.file_writer import FileWriter if __name__ == '__main__': if len(sys.argv) != 3: print('Must specify input file and output file only') quit() else: input_file_str = sys.argv[1] output_file_str = sys.argv[2] try: input_file = open(input_file_str, 'r') output_file = open(output_file_str, 'w') except: print('Error opening file') quit() fileReader = FileReader(input_file) fileWriter = FileWriter(output_file) M, N, P, Q = fileReader.get_params_generator() sudoku_board = SudokuBoardGenerator(M, N, P, Q) sudoku_board.generate_board() board_as_lists = sudoku_board.convert_board_to_list() fileWriter.write_generated_board_to_file(N, P, Q, board_as_lists)