human
What is a code to lexicographically smallest binary string formed by flipping bits at indices not divisible K1 or K2 such that count of 1 s is always greater than 0 s from left and the other steps required given the following:
Lexicographically smallest binary string formed by flipping bits at indices not divisible K1 or K2 such that count of 1 s is always greater than 0 s from left | Function to find lexicographically smallest string having number of 1 s greater than number of 0 s.
C1s And C0s stores the count of 1 s and 0 s at every position.
Traverse the string S.
If the position is not divisible by k1 and k2.
If C0s >= C1s and pos [ ] is empty then the string can 't  be formed.
If pos [ ] is not empty then flip the bit of last position present in pos [ ].
Print the result.
Driver Code"
How can the above be solved in Python?
assistant
#Here is code to lexicographically smallest binary string formed by flipping bits at indices not divisible K1 or K2 such that count of 1 s is always greater than 0 s from left and the other steps required.
 def generateString ( k1 , k2 , s ) :
	s = list ( s )
	C1s = 0
	C0s = 0
	flag = 0
	pos = [ ]
	for i in range ( len ( s ) ) :
		if ( s [ i ] == '0' ) :
			C0s += 1
			if ( ( i + 1 ) % k1 != 0 and ( i + 1 ) % k2 != 0 ) :
				pos . append ( i )
		else :
			C1s += 1
		if ( C0s >= C1s ) :
			if ( len ( pos ) == 0 ) :
				print ( - 1 )
				flag = 1
				break
			else :
				k = pos [ len ( pos ) - 1 ]
				s [ k ] = '1'
				C0s -= 1
				C1s += 1
				pos = pos [ : - 1 ]
	s = ' ' . join ( s )
	if ( flag == 0 ) :
		print ( s )
if __name__ == ' _ _ main _ _ ' :
	K1 = 2
	K2 = 4
	S = "11000100"
	generateString ( K1 , K2 , S )