Beispiel #1
0
    def test_modify_initial_cell(self):

        c = Cell(9, 0, 0, 4, is_initial=True)

        with self.assertRaises(ValueError):
            c.set_possible_value(3)

        with self.assertRaises(ValueError):
            c.set_value(5)

        with self.assertRaises(ValueError):
            c.clear_value(6)

        with self.assertRaises(ValueError):
            c.clear_possible_value(2)
Beispiel #2
0
def _clear_possible_action(board: Board, mod_cell: Cell, value: int):
    if mod_cell.is_initial():
        return

    if mod_cell.value() is not None:
        return

    if mod_cell.has_possible_val(value):
        new_cell = mod_cell.clear_possible_value(value)
        board.set_cell(new_cell)
Beispiel #3
0
    def test_clear_possible_value(self):

        c = Cell(9, 0, 0, poss_vals=frozenset({2, 3, 4}))

        c2 = c

        for i in range(1, 10):
            c2 = c2.clear_possible_value(i)

        self.assertEqual({2, 3, 4}, c.possible_vals())
        self.assertEqual(set(), c2.possible_vals())

        c2 = c.clear_possible_value(5)
        self.assertEqual(c, c2)

        c2 = c.clear_possible_value(4)
        self.assertEqual({2, 3}, c2.possible_vals())
        self.assertEqual({2, 3, 4}, c.possible_vals())

        c = Cell(9, 0, 0, 4)