import math


def closest_column(board, mouse_pos, settings):
    """
    Returns the column number in `board` closest to the given mouse position.
    """

    x_pos = mouse_pos[0] - settings.padding_left
    y_pos = mouse_pos[1] - settings.padding_top

    # restrict the clicked position to be within the board
    if x_pos < 0 or x_pos > settings.board_size[0]:
        return None

    if y_pos < 0 or y_pos > settings.board_size[0]:
        return None

    col = int(math.floor(x_pos / board.cell_length))

    return col