human
Minimum Numbers of cells that are connected with the smallest path between 3 given cells | Function to return the minimum cells that are connected via the minimum length path.
Array to store column number of the given cells.
Sort cells in ascending order of row number.
Middle row number.
Set pair to store required cells.
Range of column number.
Store all cells of middle row within column number range.
Final step to store all the column number of 1 st and 3 rd cell upto MidRow.
Driver Code.
vector pair to store X , Y , Z"
How can the above be solved in Python?
assistant
#Here is code to minimum Numbers of cells that are connected with the smallest path between 3 given cells and the other steps required.
 def Minimum_Cells ( v ) :
	col = [ 0 ] * 3
	for i in range ( 3 ) :
		column_number = v [ i ] [ 1 ]
		col [ i ] = column_number
	col . sort ( )
	v . sort ( )
	MidRow = v [ 1 ] [ 0 ]
	s = set ( )
	Maxcol = col [ 2 ]
	MinCol = col [ 0 ]
	for i in range ( MinCol , int ( Maxcol ) + 1 ) :
		s . add ( ( MidRow , i ) )
	for i in range ( 3 ) :
		if ( v [ i ] [ 0 ] == MidRow ) :
			continue ;
		for j in range ( min ( v [ i ] [ 0 ] , MidRow ) , max ( v [ i ] [ 0 ] , MidRow ) + 1 ) :
			s . add ( ( j , v [ i ] [ 1 ] ) ) ;
	return len ( s )
if __name__ == " _ _ main _ _ " :
	v = [ ( 0 , 0 ) , ( 1 , 1 ) , ( 2 , 2 ) ]
	print ( Minimum_Cells ( v ) )