Пример #1
0
    def check_solution(brett, xIndex, yIndex, solution):

        # check if number is already in x row or y column
        inX = np.any(brett[xIndex, :] == solution)
        inY = np.any(brett[:, yIndex] == solution)

        # check if number is in 3x3 box
        [xBox, yBox] = SudokuBoard.get_box_index(xIndex, yIndex)
        box = brett[xBox[0]:xBox[1] + 1, yBox[0]:yBox[1] + 1]
        inBox = np.any(box == np.ones(box.shape) * solution)

        if inX or inY or inBox:
            return 'incorrect'
        else:
            return 'correct'