Function to calculate the total possible ways
def ways ( m , w , n , k ) : NEW_LINE INDENT ans = 0 NEW_LINE while ( m >= k ) : NEW_LINE INDENT ans += ncr ( m , k ) * ncr ( w , n - k ) NEW_LINE k += 1 NEW_LINE DEDENT return ans ; NEW_LINE DEDENT