Find the coordinates of the fourth vertex of a rectangle with given 3 vertices | Function that return the coordinates of the fourth vertex of the rectangle ; Save the coordinates of the given vertices of the rectangle ; 1 - based indexing ; Driver code
def findFourthVertex ( n , m , s ) : NEW_LINE INDENT row = dict . fromkeys ( range ( n ) , 0 ) NEW_LINE col = dict . fromkeys ( range ( m ) , 0 ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT for j in range ( m ) : NEW_LINE INDENT if ( s [ i ] [ j ] == ' * ' ) : NEW_LINE INDENT row [ i ] += 1 ; NEW_LINE col [ j ] += 1 ; NEW_LINE DEDENT DEDENT DEDENT for keys , values in row . items ( ) : NEW_LINE INDENT if ( values == 1 ) : NEW_LINE INDENT x = keys ; NEW_LINE DEDENT DEDENT for keys , values in col . items ( ) : NEW_LINE INDENT if ( values == 1 ) : NEW_LINE INDENT y = keys ; NEW_LINE DEDENT DEDENT return ( x + 1 , y + 1 ) ; NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT s = [ " * . * " , " * . . " , " . . . " ] NEW_LINE n = len ( s ) ; NEW_LINE m = len ( s [ 0 ] ) ; NEW_LINE rs = findFourthVertex ( n , m , s ) ; NEW_LINE print ( rs [ 0 ] , rs [ 1 ] ) NEW_LINE DEDENT