human
Count number of rotated strings which have more number of vowels in the first half than second half | Function to return the count of rotated strings which have more number of vowels in the first half than the second half.
Compute the number of vowels in first - half.
Compute the number of vowels in second - half.
Check if first - half has more vowels.
Check for all possible rotations.
Return the answer.
Driver code.
Function call"
How can the above be solved in Python?
assistant
#Here is code to count number of rotated strings which have more number of vowels in the first half than second half and the other steps required.
 def cntRotations ( s , n ) :
	lh , rh , ans = 0 , 0 , 0
	for i in range ( n // 2 ) :
		if ( s [ i ] == ' a ' or s [ i ] == ' e ' or s [ i ] == ' i ' or s [ i ] == ' o ' or s [ i ] == ' u ' ) :
			lh += 1
	for i in range ( n // 2 , n ) :
		if ( s [ i ] == ' a ' or s [ i ] == ' e ' or s [ i ] == ' i ' or s [ i ] == ' o ' or s [ i ] == ' u ' ) :
			rh += 1
	if ( lh > rh ) :
		ans += 1
	for i in range ( 1 , n ) :
		if ( s [ i - 1 ] == ' a ' or s [ i - 1 ] == ' e ' or s [ i - 1 ] == ' i ' or s [ i - 1 ] == ' o ' or s [ i - 1 ] == ' u ' ) :
			rh += 1
			lh -= 1
		if ( s [ ( i - 1 + n // 2 ) % n ] == ' a ' or s [ ( i - 1 + n // 2 ) % n ] == ' e ' or s [ ( i - 1 + n // 2 ) % n ] == ' i ' or s [ ( i - 1 + n // 2 ) % n ] == ' o ' or s [ ( i - 1 + n // 2 ) % n ] == ' u ' ) :
			rh -= 1
			lh += 1
		if ( lh > rh ) :
			ans += 1
	return ans
if __name__ == " _ _ main _ _ " :
	s = " abecidft "
	n = len ( s )
	print ( cntRotations ( s , n ) )