human
Minimum bit changes in Binary Circular array to reach a index | finding which path have minimum flip bit and the minimum flip bits.
concatenating given string to itself , to make it circular.
check x is greater than y . marking if output need to be opposite ..
iterate Clockwise.
if current bit is not equal to next index bit ..
iterate Anti - Clockwise.
if current bit is not equal to next index bit ..
Finding whether Clockwise or Anti - clockwise path take minimum flip ..
Driver Code"
Solution in Python:
assistant
#Here is code to minimum bit changes in Binary Circular array to reach a index and the other steps required.
 def minimumFlip ( s , x , y ) :
	s = s + s
	isOpposite = False
	if ( x > y ) :
		temp = y
		y = x ;
		x = temp
		isOpposite = True
	valClockwise = 0
	cur = s [ x ]
	for i in range ( x , y + 1 , 1 ) :
		if ( s [ i ] != cur ) :
			cur = s [ i ]
			valClockwise += 1
	valAnticlockwise = 0
	cur = s [ y ]
	x += len ( s ) - 1
	for i in range ( y , x + 1 , 1 ) :
		if ( s [ i ] != cur ) :
			cur = s [ i ]
			valAnticlockwise += 1
	if ( valClockwise <= valAnticlockwise ) :
		if ( isOpposite == False ) :
			print ( " Clockwise " , valClockwise )
		else :
			print ( " Anti - clockwise " , valAnticlockwise )
	else :
		if ( isOpposite == False ) :
			print ( " Anti - clockwise " , valAnticlockwise )
		else :
			print ( " Clockwise " , valClockwise )
if __name__ == ' _ _ main _ _ ' :
	x = 0
	y = 8
	s = "000110"
	minimumFlip ( s , x , y )