having trouble here, trying to get the counter as return, but getting none instead. I'm pretty sure this is some silly mistake on my part, but after 2hours of looking and googling, I've decided to reach out, thanks.
def minimumSwaps(arr):
def swapper(counter, arr2):
out_of_place = []
for i in range(len(arr2)):
if arr2[i] is not i + 1:
out_of_place.append([abs(arr2[i] - (i + 1)), arr2[i], i])
if len(out_of_place) == 0:
print(counter, arr2)
return counter
out_of_place = sorted(out_of_place, reverse=True)
max1 = out_of_place[0]
max2 = out_of_place[1]
arr2[max1[2]] = max2[1]
arr2[max2[2]] = max1[1]
counter += 1
swapper(counter, arr2)
return swapper(0, arr)
print(minimumSwaps([1, 3, 5, 2, 4, 6, 7]))