def valid(board, number, position):
    """
    This function checks, if the number inserted is valid or not
    according to the empty spaces, that we represented as 0.
    Actually this is the main algorithm that uses the backtracking
    technique, which is, when it places a number and go forward and it
    check that if the next is not corrected it checks it again with
    the number it places lastly.
    :param board: the sudoku board
    :param number: the inserted inserted
    :param position: the empty space's position we've returned from find_empty() method
    :return: Whether the position for the number is valid or not
    """

    # check row, i is representing the rows
    for i in range(len(board)):
        # if the board at this place equals the number
        # which comes from the solve method
        if board[position[0]][i] == number and position[1] != i:
            return False

    # check columns, j is representing the columns
    for j in range(len(board)):
        # if the board at this place equals the number
        # which comes from the solve method
        if board[j][position[1]] == number and position[0] != j:
            return False

    # check the box now
    box_x = position[1] // 3
    box_y = position[0] // 3

    for i in range(box_y * 3, box_y * 3 + 3):
        for j in range(box_x * 3, box_x * 3 + 3):
            if board[i][j] == number and (i, j) != position:
                return False
    return True