Example #1
0
def thread_solver(i):
    global s, num_threads
    num_threads += 1
    csp = e02_csp.create_sudoku_csp(sudokus[i])
    solution, _ = e02_csp.minimum_remaining_values_with_degree(csp)
    solution = e02_csp.sudoku_csp_to_array(csp)
    lock.acquire();
    s += int( str(solution[0][0]) + str(solution[0][1]) + str(solution[0][2]) )
    num_threads -= 1
    lock.release()
Example #2
0
 def test_mrv_with_degree_order(self):
     csp_solution, order = \
         e02.minimum_remaining_values_with_degree(self.csp)
     self.assertEqual(order[0].name, "Niedersachsen")
     self.assertEqual(order[1].name, "Hessen")
     self.assertEqual(order[2].name, "Thueringen")
     self.assertEqual(order[3].name, "Sachsen-Anhalt")
     self.assertEqual(order[4].name, "Brandenburg")
     self.assertEqual(order[5].name, "Bayern")
     self.assertEqual(order[6].name, "Sachsen")
     self.assertEqual(order[7].name, "Mecklenburg-Vorpommern")
     self.assertEqual(order[8].name, "Schleswig-Holstein")
     self.assertEqual(order[9].name, "Nordrhein-Westfalen")
     self.assertEqual(order[10].name, "Rheinland-Pfalz")
     self.assertEqual(order[11].name, "Hamburg")
     self.assertEqual(order[12].name, "Baden-Wuerttemberg")
     self.assertEqual(order[13].name, "Bremen")
     self.assertEqual(order[14].name, "Berlin")
     self.assertEqual(order[15].name, "Saarland")
Example #3
0
 def test_mrv_with_degree(self):
     csp_solution, order = \
         e02.minimum_remaining_values_with_degree(self.csp)
     self.assertTrue(csp_solution.complete())
     print(order)