human
Generate an Array in which count of even and odd sum sub | Function to generate and print the required array.
Find the number of odd prefix sums.
If no odd prefix sum found.
Calculating the number of even prefix sums.
Stores the current prefix sum.
If current prefix sum is even.
Print 0 until e = EvenPreSums - 1.
Print 1 when e = EvenPreSums.
Print 0 for rest of the values.
Driver code"
Solution in Python:
assistant
#Here is code to generate an Array in which count of even and odd sum sub and the other steps required.
 def CreateArray ( N , even , odd ) :
	temp = - 1
	for i in range ( N + 2 ) :
		if ( i * ( ( N + 1 ) - i ) == odd ) :
			temp = 0
			OddPreSums = i
			break
	if ( temp == - 1 ) :
		print ( temp )
	else :
		EvenPreSums = ( N + 1 ) - OddPreSums
		e = 1
		o = 0
		CurrSum = 0
		for i in range ( N ) :
			if ( CurrSum % 2 == 0 ) :
				if ( e < EvenPreSums ) :
					e += 1
					print ( "0 ▁ " , end = " " )
				else :
					o += 1
					print ( "1 ▁ " , end = " " )
					CurrSum += 1
			else :
				if ( e < EvenPreSums ) :
					e += 1
					print ( "1 ▁ " )
					CurrSum += 1
				else :
					o += 1
					print ( "0 ▁ " , end = " " )
		print ( " " , ▁ end ▁ = ▁ " " )
if __name__ == ' _ _ main _ _ ' :
	N = 15
	even = 60
	odd = 60
	CreateArray ( N , even , odd )