Check if a right | Storing all the possible changes to make the triangle right - angled ; Function to check if the triangle is right - angled or not ; Function to check if the triangle can be transformed to right - angled ; Boolean variable to return true or false ; If it is already right - angled ; Applying the changes on the co - ordinates ; Applying on the first co - ordinate ; Applying on the second co - ordinate ; Applying on the third co - ordinate ; If can 't be transformed ; Driver Code
dx = [ - 1 , 0 , 1 , 0 ] NEW_LINE dy = [ 0 , 1 , 0 , - 1 ] NEW_LINE def ifRight ( x1 , y1 , x2 , y2 , x3 , y3 ) : NEW_LINE INDENT a = ( ( x1 - x2 ) * ( x1 - x2 ) ) + ( ( y1 - y2 ) * ( y1 - y2 ) ) NEW_LINE b = ( ( x1 - x3 ) * ( x1 - x3 ) ) + ( ( y1 - y3 ) * ( y1 - y3 ) ) NEW_LINE c = ( ( x2 - x3 ) * ( x2 - x3 ) ) + ( ( y2 - y3 ) * ( y2 - y3 ) ) NEW_LINE if ( ( a == ( b + c ) and a != 0 and b != 0 and c != 0 ) or ( b == ( a + c ) and a != 0 and b != 0 and c != 0 ) or ( c == ( a + b ) and a != 0 and b != 0 and c != 0 ) ) : NEW_LINE INDENT return 1 NEW_LINE DEDENT DEDENT def isValidCombination ( x1 , y1 , x2 , y2 , x3 , y3 ) : NEW_LINE INDENT x , y = 0 , 0 NEW_LINE possible = 0 NEW_LINE if ( ifRight ( x1 , y1 , x2 , y2 , x3 , y3 ) ) : NEW_LINE INDENT print ( " ALREADY ▁ RIGHT ▁ ANGLED " ) NEW_LINE return NEW_LINE DEDENT else : NEW_LINE INDENT for i in range ( 4 ) : NEW_LINE INDENT x = dx [ i ] + x1 NEW_LINE y = dy [ i ] + y1 NEW_LINE if ( ifRight ( x , y , x2 , y2 , x3 , y3 ) ) : NEW_LINE INDENT print ( " POSSIBLE " ) NEW_LINE return NEW_LINE DEDENT x = dx [ i ] + x2 NEW_LINE y = dy [ i ] + y2 NEW_LINE if ( ifRight ( x1 , y1 , x , y , x3 , y3 ) ) : NEW_LINE INDENT print ( " POSSIBLE " ) NEW_LINE return NEW_LINE DEDENT x = dx [ i ] + x3 NEW_LINE y = dy [ i ] + y3 NEW_LINE if ( ifRight ( x1 , y1 , x2 , y2 , x , y ) ) : NEW_LINE INDENT print ( " POSSIBLE " ) NEW_LINE return NEW_LINE DEDENT DEDENT DEDENT if ( possible == 0 ) : NEW_LINE INDENT print ( " NOT ▁ POSSIBLE " ) NEW_LINE DEDENT DEDENT x1 = - 49 NEW_LINE y1 = 0 NEW_LINE x2 = 0 NEW_LINE y2 = 50 NEW_LINE x3 = 0 NEW_LINE y3 = - 50 NEW_LINE isValidCombination ( x1 , y1 , x2 , y2 , x3 , y3 ) NEW_LINE