Minimum and maximum possible length of the third side of a triangle | Function to find the minimum and the maximum possible length of the third side of the given triangle ; Not a valid triangle ; Not a valid triangle ; Driver code
def find_length ( s1 , s2 ) : NEW_LINE INDENT if ( s1 <= 0 or s2 <= 0 ) : NEW_LINE INDENT print ( - 1 , end = " " ) ; NEW_LINE return ; NEW_LINE DEDENT max_length = s1 + s2 - 1 ; NEW_LINE min_length = max ( s1 , s2 ) - min ( s1 , s2 ) + 1 ; NEW_LINE if ( min_length > max_length ) : NEW_LINE INDENT print ( - 1 , end = " " ) ; NEW_LINE return ; NEW_LINE DEDENT print ( " Max ▁ = " , max_length ) ; NEW_LINE print ( " Min ▁ = " , min_length ) ; NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT s1 = 8 ; NEW_LINE s2 = 5 ; NEW_LINE find_length ( s1 , s2 ) ; NEW_LINE DEDENT