human
Write me a code to number of ways to sum up a total of N from limited denominations and the other steps required given the following:
Number of ways to sum up a total of N from limited denominations | Function to find the number of ways to sum up a total of N from limited denominations.
Store the count of denominations.
Stores the final result.
As one of the denominations is rupee 1 , so we can reduce the computation by checking the equality for N - ( A * 1 ) = N - A.
Increment the count for number of ways.
Driver Code.
Given Denominations.
Function Call"
How can the above be solved in Python?
assistant
#Here is code to number of ways to sum up a total of N from limited denominations and the other steps required.
 def calculateWays ( arr1 , arr2 , N ) :
	A = arr2 [ 0 ]
	B = arr2 [ 1 ]
	C = arr2 [ 2 ]
	D = arr2 [ 3 ]
	ans , b , c , d = 0 , 0 , 0 , 0
	while b <= B and b * 5 <= ( N ) :
		c = 0
		while ( c <= C and b * 5 + c * 10 <= ( N ) ) :
			d = 0
			while ( d <= D and b * 5 + c * 10 + d * 20 <= ( N ) ) :
				if ( ( b * 5 ) + ( c * 10 ) + ( d * 20 ) >= ( N - A ) ) :
					ans += 1
				d += 1
			c += 1
		b += 1
	return ans
if __name__ == ' _ _ main _ _ ' :
	N = 123
	arr1 = [ 1 , 5 , 10 , 20 ]
	arr2 = [ 6 , 4 , 3 , 5 ]
	print ( calculateWays ( arr1 , arr2 , N ) )