Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Uncategorized category for Count Inversions by UFO665
def count_inversion(seq):
counter = 0
lst = list(seq)
while lst != sorted(lst):
for i in range(len(lst) - 1):
if lst[i] > lst[i + 1]:
lst[i], lst[i + 1], counter = lst[i + 1], lst[i], counter + 1
return counter
Dec. 4, 2015