コード例 #1
0
 def test_single(self):
     self.assertEqual(0, get_number_of_inversions([1], [0], 0, 1))
コード例 #2
0
 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))
コード例 #3
0
 def test_empty(self):
     self.assertEqual(0, get_number_of_inversions([], [], 0, 0))
コード例 #4
0
 def test_sample(self):
     self.assertEqual(2, get_number_of_inversions([2, 3, 9, 2, 9], [0, 0, 0, 0, 0], 0, 5))
コード例 #5
0
 def test_three_desc(self):
     self.assertEqual(3, get_number_of_inversions([3, 2, 1], [0, 0, 0], 0, 3))
コード例 #6
0
 def test_two_desc(self):
     self.assertEqual(1, get_number_of_inversions([2, 1], [0, 0], 0, 2))
コード例 #7
0
 def test_two_asc(self):
     self.assertEqual(0, get_number_of_inversions([1, 2], [0, 0], 0, 2))
コード例 #8
0
ファイル: inversions_test.py プロジェクト: fluxgame/ALGS200x
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