human
Check whether two strings are equivalent or not according to given condition | This function returns the least lexicogr aphical string obtained from its two halves.
Base Case - If string size is 1.
Divide the string into its two halves.
Form least lexicographical string.
Driver Code"
How can the above be solved in Python?
assistant
#Here is code to check whether two strings are equivalent or not according to given condition and the other steps required.
 def leastLexiString ( s ) :
	if ( len ( s ) & 1 != 0 ) :
		return s
	x = leastLexiString ( s [ 0 : int ( len ( s ) / 2 ) ] )
	y = leastLexiString ( s [ int ( len ( s ) / 2 ) : len ( s ) ] )
	return min ( x + y , y + x )
def areEquivalent ( a , b ) :
	return ( leastLexiString ( a ) == leastLexiString ( b ) )
if __name__ == ' _ _ main _ _ ' :
	a = " aaba "
	b = " abaa "
	if ( areEquivalent ( a , b ) ) :
		print ( " YES " )
	else :
		print ( " NO " )
	a = " aabb "
	b = " abab "
	if ( areEquivalent ( a , b ) ) :
		print ( " YES " )
	else :
		print ( " NO " )