Find the minimum value of A by interchanging the digits of A and store min1 .
if ( q - p > 0 and q < min1 ) : NEW_LINE INDENT min1 = q NEW_LINE _count = 1 NEW_LINE DEDENT else : NEW_LINE for j in range ( i , n + 1 ) : NEW_LINE INDENT str1 [ i ] , str1 [ j ] = str1 [ j ] , str1 [ i ] NEW_LINE permutation ( str1 , i + 1 , n , p ) NEW_LINE str1 [ i ] , str1 [ j ] = str1 [ j ] , str1 [ i ] NEW_LINE DEDENT return min1 NEW_LINE