コード例 #1
0
ファイル: test_Sudoku.py プロジェクト: tanzhou007/Sudoku
 def test_getBoxLocations(self): 
     box0 = [(0, 0), (0, 1), (0, 2), (1, 0), 
             (1, 1), (1, 2), (2, 0), (2, 1), (2, 2)]
     getBox = sudoku.getBoxLocations((1, 2))
     for coordinate in box0:
         self.assertTrue(coordinate in getBox)
     self.assertTrue(len(box0) == len(getBox))
コード例 #2
0
def testGetBoxLocations():
    lst = [(3, 0), (3, 1), (3, 2), (4, 0), (4, 1), (4, 2), (5, 0), (5, 1),
           (5, 2)]
    assert sudoku.getBoxLocations((3, 2)) == lst

    lst = [[4, 0, 0, 0, 0, 3, 0, 7, 0], [0, 0, 1, 0, 0, 9, 5, 0, 8],
           [0, 0, 0, 6, 0, 8, 4, 1, 3], [0, 1, 0, 9, 0, 0, 3, 0, 0],
           [0, 0, 0, 0, 5, 0, 0, 0, 0], [0, 0, 4, 0, 0, 6, 0, 8, 0],
           [7, 9, 2, 8, 0, 5, 0, 0, 0], [3, 0, 5, 4, 0, 0, 9, 0, 0],
           [0, 4, 0, 2, 0, 0, 8, 0, 5]]

    assert sudoku.getBoxLocations((8, 8)) == [(6, 6), (6, 7), (6, 8), (7, 6),
                                              (7, 7), (7, 8), (8, 6), (8, 7),
                                              (8, 8)]
    assert sudoku.getBoxLocations((3, 4)) == [(3, 3), (3, 4), (3, 5), (4, 3),
                                              (4, 4), (4, 5), (5, 3), (5, 4),
                                              (5, 5)]
コード例 #3
0
ファイル: test_Sudoku.py プロジェクト: tanzhou007/Sudoku
 def test_eliminate(self):
     loc0 = (0,1)
     eliminate = sudoku.read_sudoku("./data/eliminateTest.txt")    #read the eliminate result
     problem = sudoku.read_sudoku("./data/data1.txt")  #read the puzzle
     problemSets = sudoku.convertToSets(problem)
     listOfLocation = sudoku.getRowLocations(loc0[0]) + sudoku.getColumnLocations(loc0[1]) \
                         + sudoku.getBoxLocations(loc0) 
     self.assertEqual(12, sudoku.eliminate(problemSets, loc0, listOfLocation))
     self.assertEqual(eliminate, problemSets)
コード例 #4
0
def test_getboxlocs_botright(row, col):
    botright = [(6, 6), (6, 7), (6, 8), (7, 6), (7, 7), (7, 8), (8, 6), (8, 7), (8, 8)]
    assert getBoxLocations((row, col)) == botright
コード例 #5
0
def test_getboxlocs_botmid(row, col):
    botmid = [(6, 3), (6, 4), (6, 5), (7, 3), (7, 4), (7, 5), (8, 3), (8, 4), (8, 5)]
    assert getBoxLocations((row, col)) == botmid
コード例 #6
0
def test_getboxlocs_botleft(row, col):
    botleft = [(6, 0), (6, 1), (6, 2), (7, 0), (7, 1), (7, 2), (8, 0), (8, 1), (8, 2)]
    assert getBoxLocations((row, col)) == botleft
コード例 #7
0
def test_getboxlocs_midright(row, col):
    midright = [(3, 6), (3, 7), (3, 8), (4, 6), (4, 7), (4, 8), (5, 6), (5, 7), (5, 8)]
    assert getBoxLocations((row, col)) == midright
コード例 #8
0
def test_getboxlocs_mid(row, col):
    midbox = [(3, 3), (3, 4), (3, 5), (4, 3), (4, 4), (4, 5), (5, 3), (5, 4), (5, 5)]
    assert getBoxLocations((row, col)) == midbox
コード例 #9
0
def test_getboxlocs_midleft(row, col):
    midleftbox = [(3, 0), (3, 1), (3, 2), (4, 0), (4, 1), (4, 2), (5, 0), (5, 1), (5, 2)]
    assert getBoxLocations((row, col)) == midleftbox
コード例 #10
0
def test_getboxlocs_topright(row, col):
    toprightbox = [(0, 6), (0, 7), (0, 8), (1, 6), (1, 7), (1, 8), (2, 6), (2, 7), (2, 8)]
    assert getBoxLocations((row, col)) == toprightbox
コード例 #11
0
def test_getboxlocs_topmid(row, col):
    topmidbox = [(0, 3), (0, 4), (0, 5), (1, 3), (1, 4), (1, 5), (2, 3), (2, 4), (2, 5)]
    assert getBoxLocations((row, col)) == topmidbox
コード例 #12
0
def test_getboxlocs_topleft(row, col):
    topleftbox = [(0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (1, 2), (2, 0), (2, 1), (2, 2)]
    assert getBoxLocations((row, col)) == topleftbox