human
What is a code to perimeter of the Union of Two Rectangles and the other steps required given the following:
Perimeter of the Union of Two Rectangles | Function to check if two rectangles are intersecting or not.
If one rectangle is to the right of other 's right edge.
If one rectangle is on the top of other 's top edge.
Function to return the perimeter of the Union of Two Rectangles.
Stores the resultant perimeter.
If rectangles do not interesect.
Perimeter of Rectangle 1.
Perimeter of Rectangle 2.
If the rectangles intersect.
Get width of combined figure.
Get length of combined figure.
Return the perimeter.
Driver Code"
Solution in Python:
assistant
#Here is code to perimeter of the Union of Two Rectangles and the other steps required.
 def doIntersect ( X , Y ) :
	if ( X [ 0 ] > X [ 3 ] or X [ 2 ] > X [ 1 ] ) :
		return False
	if ( Y [ 0 ] > Y [ 3 ] or Y [ 2 ] > Y [ 1 ] ) :
		return False
	return True
def getUnionPerimeter ( X , Y ) :
	perimeter = 0
	if ( not doIntersect ( X , Y ) ) :
		perimeter += 2 * ( abs ( X [ 1 ] - X [ 0 ] ) + abs ( Y [ 1 ] - Y [ 0 ] ) )
		perimeter += 2 * ( abs ( X [ 3 ] - X [ 2 ] ) + abs ( Y [ 3 ] - Y [ 2 ] ) )
	else :
		w = max ( X ) - min ( X )
		l = max ( Y ) - min ( Y )
		perimeter = 2 * ( l + w )
	return perimeter
if __name__ == ' _ _ main _ _ ' :
	X = [ - 1 , 2 , 4 , 6 ]
	Y = [ 2 , 5 , 3 , 7 ]
	print ( getUnionPerimeter ( X , Y ) )