Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Uncategorized category for Robot Sort by robert.rudko
def swapsort(array):
array = list(array)
result = []
if array == sorted(array):
return ""
while array != sorted(array):
for x in range(len(array)-1):
if array[x] > array[x+1]:
array[x], array[x+1] = array[x+1], array[x]
result.append(str(x)+str(x+1))
break
result = ','.join(result)
return result
assert check_solution(swapsort, (6, 4, 2)), "Reverse simple"
assert check_solution(swapsort, (1, 2, 3, 4, 5)), "All right!"
assert check_solution(swapsort, (1, 2, 3, 5, 3)), "One move"
Nov. 1, 2015