Beispiel #1
0
 def test_convertToInt(self):
     sets = sudoku.read_sudoku("./data/convertToSetsTest.txt")     #read the coverted sets
     problem = sudoku.read_sudoku("./data/data1.txt")  #read the puzzle
     emptySets = sudoku.read_sudoku("./data/emptySets.txt")
     self.assertEqual([[0] * 9] * 9, sudoku.convertToInts(emptySets))
     self.assertEqual(problem, sudoku.convertToInts(sets))
     self.assertEqual([problem[0]], sudoku.convertToInts([sets[0]]))
Beispiel #2
0
def testConvertToInts():
    sets = [[{1, 2}, {3}, {4}], [{1}, {3, 5, 7}, {2}], [{2, 3}, {2}, {3}]]
    assert sudoku.convertToInts(sets) == [[0, 3, 4], [1, 0, 2], [0, 2, 3]]
    assert type(
        sets[0][0]) is int, print("The original array has been changed.")
Beispiel #3
0
def ints(sets):
    return convertToInts(sets)
Beispiel #4
0
 def test_solve(self):        
     result = sudoku.read_sudoku("./data/result.txt")   #read the result 
     problem = sudoku.read_sudoku("./data/data1.txt")  #read the puzzle
     problemSets = sudoku.convertToSets(problem)
     self.assertTrue(sudoku.solve(problemSets))
     self.assertEqual(result, sudoku.convertToInts(problemSets))