human
Number of ways to obtain each numbers in range [ 1 , b + c ] by adding any two numbers in range [ a , b ] and [ b , c ] | Python3 program to calculate the number of ways.
2 is added because sometimes we will decrease the value out of bounds ..
Initialising the array with zeros ..
Printing the array.
Driver code"
How can the above be solved in Python?
assistant
#Here is code to number of ways to obtain each numbers in range [ 1 , b + c ] by adding any two numbers in range [ a , b ] and [ b , c ] and the other steps required.
 def CountWays ( a , b , c ) :
	x = b + c + 2 ;
	arr = [ 0 ] * x ;
	for i in range ( 1 , b + 1 ) :
	arr [ i + b ] = arr [ i + b ] + 1 ;
	arr [ i + c + 1 ] = arr [ i + c + 1 ] - 1 ;
	for i in range ( 1 , x - 1 ) :
	arr [ i ] += arr [ i - 1 ] ;
	print ( arr [ i ] , end = " ▁ " ) ;
if __name__ == ' _ _ main _ _ ' :
	a = 1 ;
	b = 2 ;
	c = 2 ;
	CountWays ( a , b , c ) ;