fork(1) download
  1. def count_inversion(sequence):
  2. count = 0
  3. """
  4. Count inversions in a sequence of numbers
  5. """
  6. for i in range(len(sequence)):
  7. for j in range(i+1, len(sequence)):
  8. if sequence[i] > sequence[j]:
  9. count +=1
  10. return count
Success #stdin #stdout 0.02s 8736KB
stdin
Standard input is empty
stdout
Standard output is empty