Пример #1
0
 def mat_test(self):
     m = [[1, 8, 7, 4, 9, 3, 6, 5, 2], [6, 4, 3, 1, 2, 5, 8, 9, 7],
          [2, 5, 9, 7, 8, 6, 3, 1, 4], [7, 1, 4, 2, 3, 8, 5, 6, 9],
          [9, 6, 8, 5, 7, 1, 4, 2, 3], [5, 3, 2, 6, 4, 9, 1, 7, 8],
          [8, 7, 6, 9, 1, 4, 2, 3, 5], [4, 9, 1, 3, 5, 2, 7, 8, 6],
          [3, 2, 5, 8, 6, 7, 9, 4, 1]]
     assert (Sudoku(m).mat == m)
Пример #2
0
    def loads_test1(self):
        assert(Sudoku.loads("""
        [
            [
                [1, 8, 7, 4, 9, 3, 6, 5, 2],
                [6, 4, 3, 1, 2, 5, 8, 9, 7],
                [2, 5, 9, 7, 8, 6, 3, 1, 4],

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

                [8, 7, 6, 9, 1, 4, 2, 3, 5],
                [4, 9, 1, 3, 5, 2, 7, 8, 6],
                [3, 2, 5, 8, 6, 7, 9, 4, 1]
            ]
        ]
        """) == [Sudoku([
            [1, 8, 7, 4, 9, 3, 6, 5, 2],
            [6, 4, 3, 1, 2, 5, 8, 9, 7],
            [2, 5, 9, 7, 8, 6, 3, 1, 4],

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

            [8, 7, 6, 9, 1, 4, 2, 3, 5],
            [4, 9, 1, 3, 5, 2, 7, 8, 6],
            [3, 2, 5, 8, 6, 7, 9, 4, 1]
        ]
        )])
Пример #3
0
    def loads_test4(self):
        # only sudoku, not list of sudoku
        Sudoku.loads("""
            [
                [1, 8, 7, 4, 9, 3, 6, 5, 2],
                [6, 4, 3, 1, 2, 5, 8, 9, 7],
                [2, 5, 9, 7, 8, 6, 3, 1, 4],

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

                [8, 7, 6, 9, 1, 4, 2, 3, 5],
                [4, 9, 1, 3, 5, 2, 7, 8, 6],
                [3, 2, 5, 8, 6, 7, 9, 4, 1]
            ]
        """)
Пример #4
0
    def loads_test4(self):
        # only sudoku, not list of sudoku
        Sudoku.loads("""
            [
                [1, 8, 7, 4, 9, 3, 6, 5, 2],
                [6, 4, 3, 1, 2, 5, 8, 9, 7],
                [2, 5, 9, 7, 8, 6, 3, 1, 4],

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

                [8, 7, 6, 9, 1, 4, 2, 3, 5],
                [4, 9, 1, 3, 5, 2, 7, 8, 6],
                [3, 2, 5, 8, 6, 7, 9, 4, 1]
            ]
        """)
Пример #5
0
    def loads_test3(self):
        Sudoku.loads("""
        [
            [
                ["a", 8, 7, 4, 9, 3, 6, 5, 2],
                [6, 4, 3, 1, 2, 5, 8, 9, 7],
                [2, 5, 9, 7, 8, 6, 3, 1, 4],

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

                [8, 7, 6, 9, 1, 4, 2, 3, 5],
                [4, 9, 1, 3, 5, 2, 7, 8, 6],
                [3, 2, 5, 8, 6, 7, 9, 4, 1]
            ]
        ]
        """)
Пример #6
0
    def loads_test3(self):
        Sudoku.loads("""
        [
            [
                ["a", 8, 7, 4, 9, 3, 6, 5, 2],
                [6, 4, 3, 1, 2, 5, 8, 9, 7],
                [2, 5, 9, 7, 8, 6, 3, 1, 4],

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

                [8, 7, 6, 9, 1, 4, 2, 3, 5],
                [4, 9, 1, 3, 5, 2, 7, 8, 6],
                [3, 2, 5, 8, 6, 7, 9, 4, 1]
            ]
        ]
        """)
Пример #7
0
    def loads_test2(self):
        assert (Sudoku.loads("""
        [
            [
                [1, 8, 7, 4, 9, 3, 6, 5, 2],
                [6, 4, 3, 1, 2, 5, 8, 9, 7],
                [2, 5, 9, 7, 8, 6, 3, 1, 4],

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

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

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

                [4, 2, 7, 1, 8, 3, 6, 5, 9],
                [5, 6, 1, 4, 9, 2, 8, 3, 7],
                [9, 3, 8, 7, 5, 6, 2, 4, 1]
            ]
        ]
        """) == [
            Sudoku([[1, 8, 7, 4, 9, 3, 6, 5, 2], [6, 4, 3, 1, 2, 5, 8, 9, 7],
                    [2, 5, 9, 7, 8, 6, 3, 1, 4], [7, 1, 4, 2, 3, 8, 5, 6, 9],
                    [9, 6, 8, 5, 7, 1, 4, 2, 3], [5, 3, 2, 6, 4, 9, 1, 7, 8],
                    [8, 7, 6, 9, 1, 4, 2, 3, 5], [4, 9, 1, 3, 5, 2, 7, 8, 6],
                    [3, 2, 5, 8, 6, 7, 9, 4, 1]]),
            Sudoku([[8, 4, 6, 9, 2, 7, 5, 1, 3], [3, 5, 2, 8, 4, 1, 9, 7, 6],
                    [7, 1, 9, 6, 3, 5, 4, 2, 8], [1, 7, 4, 5, 6, 9, 3, 8, 2],
                    [6, 8, 3, 2, 1, 4, 7, 9, 5], [2, 9, 5, 3, 7, 8, 1, 6, 4],
                    [4, 2, 7, 1, 8, 3, 6, 5, 9], [5, 6, 1, 4, 9, 2, 8, 3, 7],
                    [9, 3, 8, 7, 5, 6, 2, 4, 1]])
        ])
Пример #8
0
 def setUp(self):
     sudoku = Sudoku([[1, 8, 7, 4, 9, 3, 6, 5, 2],
                      [6, 4, 3, 1, 2, 5, 8, 9, 7],
                      [2, 5, 9, 7, 8, 6, 3, 1, 4],
                      [7, 1, 4, 2, 3, 8, 5, 6, 9],
                      [9, 6, 8, 5, 7, 1, 4, 2, 3],
                      [5, 3, 2, 6, 4, 9, 1, 7, 8],
                      [8, 7, 6, 9, 1, 4, 2, 3, 5],
                      [4, 9, 1, 3, 5, 2, 7, 8, 6],
                      [3, 2, 5, 8, 6, 7, 9, 4, 1]])
     self.sudoku_info = SudokuPageInfo(sudoku,
                                       "title",
                                       show_title=False,
                                       show_page_number=True)
Пример #9
0
 def loads_test5(self):
     Sudoku.loads('"abc"')
Пример #10
0
 def loads_test5(self):
     Sudoku.loads('"abc"')