human
Count number of ways to get Odd Sum | Count the ways to sum up with odd by choosing one element form each pair.
Initialize two array with 0.
if element is even.
store count of even number in i 'th pair.
if the element is odd.
store count of odd number in i 'th pair.
Initial state of dp array.
dp [ i ] [ 0 ] = total number of ways to get even sum upto i 'th pair.
dp [ i ] [ 1 ] = total number of ways to odd even sum upto i 'th pair.
dp [ n - 1 ] [ 1 ] = total number of ways to get odd sum upto n 'th pair.
Driver code"
How can the above be solved in Python?
 ... Can you provide a code to count number of ways to get Odd Sum and the other steps required?
assistant
#Here is code to count number of ways to get Odd Sum and the other steps required.
 def CountOfOddSum ( a , n ) :
	dp = [ [ 0 for i in range ( 2 ) ] for i in range ( n ) ]
	cnt = [ [ 0 for i in range ( 2 ) ] for i in range ( n ) ]
	for i in range ( n ) :
		for j in range ( 2 ) :
			if ( a [ i ] [ j ] % 2 == 0 ) :
				cnt [ i ] [ 0 ] += 1
			else :
				cnt [ i ] [ 1 ] += 1
	dp [ 0 ] [ 0 ] = cnt [ 0 ] [ 0 ]
	dp [ 0 ] [ 1 ] = cnt [ 0 ] [ 1 ]
	for i in range ( 1 , n ) :
		dp [ i ] [ 0 ] = ( dp [ i - 1 ] [ 0 ] * cnt [ i ] [ 0 ] + dp [ i - 1 ] [ 1 ] * cnt [ i ] [ 1 ] )
		dp [ i ] [ 1 ] = ( dp [ i - 1 ] [ 0 ] * cnt [ i ] [ 1 ] + dp [ i - 1 ] [ 1 ] * cnt [ i ] [ 0 ] )
	return dp [ n - 1 ] [ 1 ]
a = [ [ 1 , 2 ] , [ 3 , 6 ] ]
n = len ( a )
ans = CountOfOddSum ( a , n )
print ( ans )