def closest_color(rgb, colors):
    """
    Determine the closest color in `colors` to `rgb`.

    WARNING: this function is *destructive*. It removes the result from the input
    `colors` list. This is to prevent overlapping colors in the color assignment below
    (starting line 263). It is recommended to pass a copied list to this function if you
    wish to protect the original list.

    Parameters
    ----------
    rgb : tuple[int]
        An RGB color.
    colors : list[tuple[int]]

    Returns
    -------
    tuple[int]
        An RGB color.
    """
    r, g, b = rgb
    color_diffs = []
    for color in colors:
        cr, cg, cb = color
        color_diff = (abs(r - cr) ** 2 + abs(g - cg) ** 2 + abs(b - cb) ** 2) ** (1 / 2)
        color_diffs.append((color_diff, color))
    result = min(color_diffs)[1]
    colors.remove(result)
    return result