Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Count Inversions by wolicki.mikolaj
def count_inversion(s):
"""
Count inversions in a sequence of numbers
"""
t=len(s)
wynik=0
o=1
for i in s:
#print i, 0
#print o,11111
if (oj:
wynik=wynik+1
#print("dodan")
o=o+1
return wynik
if __name__ == '__main__':
#These "asserts" using only for self-checking and not necessary for auto-testing
assert count_inversion((1, 2, 5, 3, 4, 7, 6)) == 3, "Example"
#assert count_inversion((0, 1, 2, 3)) == 0, "Sorted"
#assert count_inversion((99, -99)) == 1, "Two numbers"
#assert count_inversion((5, 3, 2, 1, 0)) == 10, "Reversed"
Nov. 25, 2016