Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Uncategorized category for Robot Sort by TovarischZhukov
def swapsort(array):
array = list(array)
i=0
is_find=False
retval=[]
while 1:
if i==(len(array)-1):
i=0
if not is_find: break
else: is_find = False
if array[i]>array[i+1]:
is_find=True
retval.append("%i%i"%(i, i+1))
array[i], array[i+1]=array[i+1], array[i]
i+=1
return ",".join(retval)
Dec. 23, 2015