human
Lexicographically n | Function to print nth permutation using next_permute ( ).
Sort the string in lexicographically ascending order.
Keep iterating until we reach nth position.
check for nth iteration.
print string after nth iteration.
next_permutation method implementation.
Driver Code"
Solution in Python:
assistant
#Here is code to lexicographically n and the other steps required.
 def nPermute ( string , n ) :
	string = list ( string )
	new_string = [ ]
	string . sort ( )
	j = 2
	while next_permutation ( string ) :
		new_string = string
		if j == n :
			break
		j += 1
	print ( ' ' . join ( new_string ) )
def next_permutation ( L ) :
	n = len ( L )
	i = n - 2
	while i >= 0 and L [ i ] >= L [ i + 1 ] :
		i -= 1
	if i == - 1 :
		return False
	j = i + 1
	while j < n and L [ j ] > L [ i ] :
		j += 1
	j -= 1
	L [ i ] , L [ j ] = L [ j ] , L [ i ]
	left = i + 1
	right = n - 1
	while left < right :
		L [ left ] , L [ right ] = L [ right ] , L [ left ]
		left += 1
		right -= 1
	return True
if __name__ == " _ _ main _ _ " :
	string = " GEEKSFORGEEKS "
	n = 100
	nPermute ( string , n )