human
Write me a code to count of different straight lines with total n points with m collinear and the other steps required given the following:
Count of different straight lines with total n points with m collinear | Returns value of binomial coefficient Code taken from https : goo . gl / vhy4jp.
C [ 0 ] = 1 nC0 is 1.
Compute next row of pascal triangle using the previous row.
function to calculate number of straight lines can be formed.
Driven code"
How can the above be solved in Python?
assistant
#Here is code to count of different straight lines with total n points with m collinear and the other steps required.
 def nCk ( n , k ) :
	C = [ 0 ] * ( k + 1 )
	for i in range ( 1 , n + 1 ) :
		j = min ( i , k )
		while ( j > 0 ) :
			C [ j ] = C [ j ] + C [ j - 1 ]
			j = j - 1
	return C [ k ]
def count_Straightlines ( n , m ) :
	return ( nCk ( n , 2 ) - nCk ( m , 2 ) + 1 )
n = 4
m = 3
print ( count_Straightlines ( n , m ) ) ;