human
Minimum steps to convert an Array into permutation of numbers from 1 to N | Function to find minimum number of steps to convert a given sequence into a permutation.
Sort the given array.
To store the required minimum number of operations.
Find the operations on each step.
Return the answer.
Driver code.
Function call"
How can the above be solved in Python?
 Give me a code to minimum steps to convert an Array into permutation of numbers from 1 to N and the other steps required?
assistant
#Here is code to minimum steps to convert an Array into permutation of numbers from 1 to N and the other steps required.
 def get_permutation ( arr , n ) :
	arr = sorted ( arr )
	result = 0
	for i in range ( n ) :
		result += abs ( arr [ i ] - ( i + 1 ) )
	return result
if __name__ == ' _ _ main _ _ ' :
	arr = [ 0 , 2 , 3 , 4 , 1 , 6 , 8 , 9 ]
	n = len ( arr )
	print ( get_permutation ( arr , n ) )