human
Give me a code to check if the tower of sight issue occurs or not and the other steps required given the following:
Check if the tower of sight issue occurs or not | Function to check if point p lies in between the line joining p1 and p2.
If parallel to X - axis.
Point p lies between p1 and p2.
If parallel to Y - axis.
Point p lies between p1 and p2.
If point p satisfies the equation of line joining p1 and p2.
Function to check if tower of sight issue occurred.
B lies between AC.
D lies between AC.
A lies between BD.
C lies between BD.
Driver code.
Point A.
Point B.
Point C.
Point D"
Solution in Python:
assistant
#Here is code to check if the tower of sight issue occurs or not and the other steps required.
 def checkIntersection ( p1 , p2 , p ) :
	if ( p1 [ 1 ] == p2 [ 1 ] and p1 [ 1 ] == p [ 1 ] ) :
		if ( p [ 0 ] <= max ( p1 [ 0 ] , p2 [ 0 ] ) and ( p [ 0 ] >= min ( p1 [ 0 ] , p2 [ 0 ] ) ) ) :
			return 1
	if ( p1 [ 0 ] == p2 [ 0 ] and p1 [ 0 ] == p [ 0 ] ) :
		if ( p [ 1 ] <= max ( p1 [ 1 ] , p2 [ 1 ] ) and ( p [ 1 ] >= min ( p1 [ 1 ] , p2 [ 1 ] ) ) ) :
			return 1
	else :
		val = ( ( p [ 1 ] - p1 [ 1 ] ) * ( p2 [ 0 ] - p1 [ 0 ] ) - ( p [ 0 ] - p1 [ 0 ] ) * ( p2 [ 1 ] - p1 [ 1 ] ) )
		if ( val == 0 ) :
			if ( ( p [ 0 ] <= max ( p1 [ 0 ] , p2 [ 0 ] ) and ( p [ 0 ] >= min ( p1 [ 0 ] , p2 [ 0 ] ) ) ) and ( p [ 1 ] <= max ( p1 [ 1 ] , p2 [ 1 ] ) and ( p [ 1 ] >= min ( p1 [ 1 ] , p2 [ 1 ] ) ) ) ) :
				return 1
	return 0
def towerOfSight ( a , b , c , d ) :
	flag = 0
	if ( checkIntersection ( a , c , b ) ) :
		flag = 1
	elif ( checkIntersection ( a , c , d ) ) :
		flag = 1
	elif ( checkIntersection ( b , d , a ) ) :
		flag = 1
	elif ( checkIntersection ( b , d , c ) ) :
		flag = 1
	if ( flag ) :
		print ( " Yes " )
	else :
		print ( " No " )
if __name__ == " _ _ main _ _ " :
	a = [ 0 , 0 ]
	b = [ 0 , - 2 ]
	c = [ 2 , 0 ]
	d = [ 0 , 2 ]
	towerOfSight ( a , b , c , d )