human
Count ways to construct array with even product from given array such that absolute difference of same indexed elements is at most 1 | Function to find count the ways to construct an array , B [ ] such that abs ( A [ i ] - B [ i ] ) <= 1 and product of elements of B [ ] is even.
Stores count of arrays B [ ] such that abs ( A [ i ] - B [ i ] ) <= 1.
Stores count of arrays B [ ] whose product of elements is not even.
Traverse the array.
Update total.
If A [ i ] is an even number.
Update oddArray.
Print 3 ^ N - 2 ^ X.
Driver Code"
How can the above be solved in Python?
assistant
#Here is code to count ways to construct array with even product from given array such that absolute difference of same indexed elements is at most 1 and the other steps required.
 def cntWaysConsArray ( A , N ) :
	total = 1 ;
	oddArray = 1 ;
	for i in range ( N ) :
		total = total * 3 ;
		if ( A [ i ] % 2 == 0 ) :
			oddArray *= 2 ;
	print ( total - oddArray ) ;
if __name__ == " _ _ main _ _ " :
	A = [ 2 , 4 ] ;
	N = len ( A ) ;
	cntWaysConsArray ( A , N ) ;