Light Mode
Dark Mode
stuck in count inversion problem

I think I am suppose count number of times series does not follow rule.

So I tried something like:

  def count_inversion(sequence):
  sequence = list(sequence)
  count = 0

  for i in sequence:
    if sequence[sequence.index(i)] - sequence[(sequence.index(i)-1)] != 1:

      count = (count + 1) 
  return count

But it is not giving me correct answer and I can't figure it out what is wrong!

Created: Nov. 16, 2015, 1:48 p.m.
Updated: Dec. 1, 2015, 3:20 p.m.
0
4
User avatar
thobhanifreddy