Beispiel #1
0
    def bas_check_row(self, rownum, change):

        # Check which values exist in the row
        found = utils.check_values(self.sudoku.loc[rownum])

        # Assign possible values based on found, return if a cell has been solved or if there is an error
        return self.bas_assign_region(self.sudoku.loc[rownum], change, found)
Beispiel #2
0
    def int_check_column(self, colnum, change):

        found = utils.check_values(self.sudoku.loc[:, colnum])
        errorcode = 0

        return self.int_check_region(self.sudoku.loc[:, colnum], found,
                                     errorcode, change)
Beispiel #3
0
    def col_to_box_check(self, colnum, change):
        # Determines, within a column, if 2 boxes have been completed. If they have, the outstanding values in that column must be placed in the remaining
        # cells in the column. Thus it is not possible to place them in any other location in that box, so remove them from the possible values of other cells in that box

        found = utils.check_values(self.sudoku.loc[:, colnum])
        errorcode = 0
        if len(found) > 5:

            incompleted_boxes = utils.eval_boxes(self.sudoku.loc[:, colnum])

            if len(incompleted_boxes) == 1:

                remove_pos = {1, 2, 3, 4, 5, 6, 7, 8, 9}.difference(found)
                box = utils.get_box(incompleted_boxes.pop(), self.sudoku)

                for cell in utils.iter_box(box):
                    if not cell.solved and cell.column != colnum:
                        change, errorcode = cell.assign_possible(
                            remove_pos, change, self.sudoku)

        return change, errorcode
Beispiel #4
0
    def row_to_box_check(self, rownum, change):
        # Determines, within a row, if 2 boxes have been completed. If they have, the outstanding values in that row must be placed in the remaining
        # cells in the row. Thus it is not possible to place them in any other location in that box, so remove them from the possible values of other cells in that box

        found = utils.check_values(self.sudoku.loc[rownum])
        errorcode = 0
        # Only check if 6 or more values have been filled in, as any less means 2 boxes couldn't have been solved
        if len(found) > 5:

            incompleted_boxes = utils.eval_boxes(self.sudoku.loc[rownum])

            if len(incompleted_boxes) == 1:

                remove_pos = {1, 2, 3, 4, 5, 6, 7, 8, 9}.difference(found)
                box = utils.get_box(incompleted_boxes.pop(), self.sudoku)

                for cell in utils.iter_box(box):
                    if not cell.solved and cell.row != rownum:
                        change, errorcode = cell.assign_possible(
                            remove_pos, change, self.sudoku)

        return change, errorcode