Question: Python 3 help! Looking for coding help! Not help with theory or pseudocode! I understand the math part but am stuck on how to implement


10:14 AA google.ca c geeksforgeeks.org Input: m = 2, w = 2, n = 3, k = 1 Output: 4 There are 2 men, 2 women. We need to make a team of size 3 with at least one man and one woman. We can make the team in following ways. mi m2 w1 mi wi w2 m2 w1 W2 mi m2 w2 Input: m = 7, W = 6, n = 5, k = 3 Output: 756 Input: m = 5, W = 6, n = 6, k = 3 Output: 281 Recommended: Please try your approach on {IDE} first, before moving on to the solution. Approach: Since, we have to take at least k men. Totals ways = Ways when 'k' men are # Returns factorial of the number def fact (n) : fact = 1 for i in range (2, n + fact *= i return fact # Function to calculate ner def ncr in, r): ncr = fact (n) // (fact (r) * fact (n - r)) return ner # Function to calculate # the total possible ways def ways (m, w, n, k): ans = 0 while (m >= k): ans += ner (m, k) * ncr (w, n - k) k += 1 return ans; # Driver code m = 7 6. n = 5 k = 3 print (ways (m, w, n, k)) # Returns factorial of the number def fact (n) : fact = 1 for i in range (2, n + fact *= i return fact # Function to calculate ner def ncr in, r): ncr = fact (n) // (fact (r) * fact (n - r)) return ner # Function to calculate # the total possible ways def ways (m, w, n, k): ans = 0 while (m >= k): ans += ner (m, k) * ncr (w, n - k) k += 1 return ans; # Driver code m = 7 n = 5 k = 3 print (ways (m, w, n, k)) 10:14 AA google.ca c geeksforgeeks.org Input: m = 2, w = 2, n = 3, k = 1 Output: 4 There are 2 men, 2 women. We need to make a team of size 3 with at least one man and one woman. We can make the team in following ways. mi m2 w1 mi wi w2 m2 w1 W2 mi m2 w2 Input: m = 7, W = 6, n = 5, k = 3 Output: 756 Input: m = 5, W = 6, n = 6, k = 3 Output: 281 Recommended: Please try your approach on {IDE} first, before moving on to the solution. Approach: Since, we have to take at least k men. Totals ways = Ways when 'k' men are
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
