Your question is Gloves Pair Selection Math. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
An IFS Cloud warehouse stores gloves in several colors. Gloves are picked one at a time in complete darkness, and the picking order is unknown. Given the available quantity for each color, calculate the minimum number of gloves that must be picked to guarantee at least one matching pair of the same color.
The result must be guaranteed for the worst possible picking order. A pair consists of two gloves with the same color. You do not need to return the colors picked or simulate a particular order.
Implement gloves_to_guarantee_pair(glove_counts), where glove_counts is a dictionary mapping a color name to its non-negative number of gloves. Return an integer representing the minimum number of picks that guarantees a matching pair. The input is guaranteed to contain enough gloves for a pair.
def gloves_to_guarantee_pair(glove_counts):