Calculating the required swaps .
if ( need_minimum > need_maximum ) : NEW_LINE INDENT swaps = swaps + need_maximum NEW_LINE num_min = num_min - need_maximum NEW_LINE need_minimum = ( need_minimum - need_maximum ) NEW_LINE need_maximum = 0 NEW_LINE DEDENT else : NEW_LINE INDENT swaps = swaps + need_minimum NEW_LINE num_max = num_max - need_minimum NEW_LINE need_maximum = ( need_maximum - need_minimum ) NEW_LINE need_minimum = 0 NEW_LINE DEDENT