human
Count rectangles generated in a given rectangle by lines drawn parallel to X and Y axis from a given set of points | Function to get the count of ractangles.
Store distinct horizontal lines.
Store distinct Vertical lines.
Insert horizontal line passing through 0.
Insert vertical line passing through 0..
Insert horizontal line passing through rectangle [ 3 ] [ 0 ].
Insert vertical line passing through rectangle [ 3 ] [ 1 ].
Insert all horizontal and vertical lines passing through the given array.
Insert all horizontal lines.
Insert all vertical lines.
Driver Code"
How can the above be solved in Python?
 ... Write me a code to count rectangles generated in a given rectangle by lines drawn parallel to X and Y axis from a given set of points and the other steps required?
assistant
#Here is code to count rectangles generated in a given rectangle by lines drawn parallel to X and Y axis from a given set of points and the other steps required.
 def cntRect ( points , N , rectangle ) :
	cntHor = set ( [ ] )
	cntVer = set ( [ ] )
	cntHor . add ( 0 )
	cntVer . add ( 0 )
	cntHor . add ( rectangle [ 3 ] [ 0 ] )
	cntVer . add ( rectangle [ 3 ] [ 1 ] )
	for i in range ( N ) :
		cntHor . add ( points [ i ] [ 0 ] )
		cntVer . add ( points [ i ] [ 1 ] )
	return ( ( len ( cntHor ) - 1 ) * ( len ( cntVer ) - 1 ) )
if __name__ == " _ _ main _ _ " :
	rectangle = [ [ 0 , 0 ] , [ 0 , 5 ] , [ 5 , 0 ] , [ 5 , 5 ] ]
	points = [ [ 1 , 2 ] , [ 3 , 4 ] ]
	N = len ( points )
	print ( cntRect ( points , N , rectangle ) )