human
Check if any pair of semicircles intersect or not | Function to check if any pairs of the semicircles intersects or not.
Stores the coordinates of all the semicircles.
x and y are coordinates.
Store the minimum and maximum value of the pair.
Push the pair in vector.
Compare one pair with other pairs.
Generating the second pair.
Extract all the second pairs one by one.
1 st condition.
2 nd condition.
If any one condition is true.
If any pair of semicircles doesn 't exists.
Driver Code"
How can the above be solved in Python?
assistant
#Here is code to check if any pair of semicircles intersect or not and the other steps required.
 def checkIntersection ( arr , N ) :
	vec = [ ]
	for i in range ( N - 1 ) :
		x = arr [ i ]
		y = arr [ i + 1 ]
		minn = min ( x , y )
		maxx = max ( x , y )
		vec . append ( [ minn , maxx ] )
	for i in range ( len ( vec ) ) :
		x = vec [ i ]
		for j in range ( len ( vec ) ) :
			y = vec [ j ]
			cond1 = ( x [ 0 ] < y [ 0 ] and x [ 1 ] < y [ 1 ] and y [ 0 ] < x [ 1 ] )
			cond2 = ( y [ 0 ] < x [ 0 ] and y [ 1 ] < x [ 1 ] and x [ 0 ] < y [ 1 ] )
			if ( cond1 or cond2 ) :
				return True
	return False
if __name__ == ' _ _ main _ _ ' :
	arr = [ 0 , 15 , 5 , 10 ]
	N = len ( arr )
	if ( checkIntersection ( arr , N ) ) :
		print ( " Yes " )
	else :
		print ( " No " )