def test_single(self):
     self.assertEqual(0, get_number_of_inversions([1], [0], 0, 1))
 def test_sample(self):
     self.assertEqual(15, get_number_of_inversions([9, 8, 7, 3, 2, 1], [0, 0, 0, 0, 0, 0], 0, 6))
 def test_empty(self):
     self.assertEqual(0, get_number_of_inversions([], [], 0, 0))
 def test_sample(self):
     self.assertEqual(2, get_number_of_inversions([2, 3, 9, 2, 9], [0, 0, 0, 0, 0], 0, 5))
 def test_three_desc(self):
     self.assertEqual(3, get_number_of_inversions([3, 2, 1], [0, 0, 0], 0, 3))
 def test_two_desc(self):
     self.assertEqual(1, get_number_of_inversions([2, 1], [0, 0], 0, 2))
 def test_two_asc(self):
     self.assertEqual(0, get_number_of_inversions([1, 2], [0, 0], 0, 2))
示例#8
0
from inversions import get_number_of_inversions, get_number_of_inversions_naive
from test.asserts import assert_equal

arrays = [[2, 3, 9, 2, 9], [9, 8, 7, 3, 2, 1]]
for a in arrays:
    assert_equal(get_number_of_inversions_naive(a),
                 get_number_of_inversions(a), "sample 3")
"""
9 > 8
9 > 8
9 > 7
9 > 7
9 > 3
9 > 2
9 > 1

8 > 1
8 > 2
8 > 3

8 > 7
8 > 7

7 > 1
7 > 2
7 > 3
7 > 1
7 > 2
7 > 3

3 > 1