Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Insertion Sort solution in Clear category for Robot Sort by bunnychai
def swapsort(array):
swaps = []
array = list(array)
for i in range(len(array)):
j = i
while j > 0 and array[j-1] > array[j]:
array[j-1], array[j] = array[j], array[j-1]
swaps.append(str(j-1) + str(j))
j -= 1
return ','.join(swaps)
July 12, 2014
Comments: