human
Move all occurrence of letter ' x ' from the string s to the end using Recursion | Recursive program to bring ' x ' to the end.
When the string is completed from reverse direction end of recursion.
If the character x is found.
Transverse the whole string.
Swap the x so that it moves to the last.
Call to the smaller problem now.
Driver code.
Size of a.
Call to rec"
How can the above be solved in Python?
assistant
#Here is code to move all occurrence of letter ' x ' from the string s to the end using Recursion and the other steps required.
 def rec ( a , i ) :
	if ( i == 0 ) :
		a . pop ( )
		print ( " " . join ( a ) )
		return
	if ( a [ i ] == ' x ' ) :
	j = i
	while ( a [ j ] != ' \0' and a [ j + 1 ] != ' \0' ) :
		( a [ j ] , a [ j + 1 ] ) = ( a [ j + 1 ] , a [ j ] )
		j += 1
	rec ( a , i - 1 )
if __name__ == " _ _ main _ _ " :
	a = [ ' g ' , ' e ' , ' e ' , ' k ' , ' x ' , ' s ' , ' x ' , ' x ' , ' k ' , ' s ' , ' \0' ]
	n = 10
	rec ( a , n - 1 )