Maximum number of pair reductions possible on a given triplet | Function to count the maximum number of pair reductions possible on a given triplet ; Convert them into an array ; Stores count of operations ; Sort the array ; If the first two array elements reduce to 0 ; Apply the operations ; Increment count ; Print the maximum count ; Given triplet
def maxOps ( a , b , c ) : NEW_LINE INDENT arr = [ a , b , c ] NEW_LINE count = 0 NEW_LINE while True : NEW_LINE INDENT arr . sort ( ) NEW_LINE if not arr [ 0 ] and not arr [ 1 ] : NEW_LINE break NEW_LINE arr [ 1 ] -= 1 NEW_LINE arr [ 2 ] -= 1 NEW_LINE count += 1 NEW_LINE DEDENT print ( count ) NEW_LINE DEDENT a , b , c = 4 , 3 , 2 NEW_LINE maxOps ( a , b , c ) NEW_LINE