예제 #1
0
def test_1_fill_k_subsets():
    tot_list = []
    assert ex8.fill_k_subsets(3, 1, tot_list) is None
    assert sorted(tot_list) == [[0], [1], [2]]

    tot_list = []
    assert ex8.fill_k_subsets(5, 1, tot_list) is None
    assert sorted(tot_list) == [[0], [1], [2], [3], [4]]
예제 #2
0
def test_2_fill_k_subsets():
    tot_list = []
    assert ex8.fill_k_subsets(3, 2, tot_list) is None
    assert sorted(tot_list) == [[0, 1], [0, 2], [1, 2]]

    tot_list = []
    assert ex8.fill_k_subsets(5, 2, tot_list) is None
    assert sorted(tot_list) == [[0, 1], [0, 2], [0, 3], [0, 4], [1, 2], [1, 3],
                                [1, 4], [2, 3], [2, 4], [3, 4]]
예제 #3
0
def test_3_fill_k_subsets():
    tot_list = []
    assert ex8.fill_k_subsets(3, 3, tot_list) is None
    assert tot_list == [[0, 1, 2]]

    tot_list = []
    ex8.fill_k_subsets(5, 3, tot_list) is None
    assert len(tot_list) == nCr(5, 3)
    result = [str(i) for i in tot_list]
    assert len(result) == len(set(result))
예제 #4
0
def test_empty_fill_k_subsets():
    tot_list = []
    assert ex8.fill_k_subsets(0, 0, tot_list) is None
    assert tot_list == [[]]

    tot_list = []
    assert ex8.fill_k_subsets(0, 5, tot_list) is None
    assert tot_list == []

    tot_list = []
    assert ex8.fill_k_subsets(5, 0, tot_list) is None
    assert tot_list == [[]]

    tot_list = []
    assert ex8.fill_k_subsets(2, 3, tot_list) is None
    assert tot_list == []
예제 #5
0
def test_4_fill_k_subsets():
    tot_list = []
    assert ex8.fill_k_subsets(10, 4, tot_list) is None
    assert len(tot_list) == nCr(10, 4)
    result = [str(i) for i in tot_list]
    assert len(result) == len(set(result))