def test_full_combinations():
    for i, j in zip(range(3, 5), range(8, 14, 2)):
        combos = set_solver.combinations(i, j, choose=False)
        # is result proper size to include all values for all positions?
        assert len(combos) == j**i
        # is result free of duplicates?
        assert len(combos) == len(set(map(str, combos)))
Example #2
0
def test_full_combinations():
    for i, j in zip(range(3, 5), range(8, 14, 2)):
        combos = set_solver.combinations(i, j, choose=False)
        # is result proper size to include all values for all positions?
        assert len(combos) == j ** i
        # is result free of duplicates?
        assert len(combos) == len(set(map(str, combos)))
def test_choose_combinations():
    for i, j in zip(range(3, 5), range(8, 14, 2)):
        combos = set_solver.combinations(i, j)
        alternative_combos = map(list, itertools.combinations(range(j), i))
        combo_set = set(map(_as_hashable, combos))
        # does this match the combinatoric expectation?
        assert len(combos) == n_choose_r(j, i)
        # are all entries unique?
        assert len(combos) == len(combo_set)
        # does this match the response from python core?
        assert combo_set == set(map(_as_hashable, alternative_combos))
        assert all([c in alternative_combos for c in combos])
Example #4
0
def test_choose_combinations():
    for i, j in zip(range(3, 5), range(8, 14, 2)):
        combos = set_solver.combinations(i, j)
        alternative_combos = map(list, itertools.combinations(range(j), i))
        combo_set = set(map(_as_hashable, combos))
        # does this match the combinatoric expectation?
        assert len(combos) == n_choose_r(j, i)
        # are all entries unique?
        assert len(combos) == len(combo_set)
        # does this match the response from python core?
        assert combo_set == set(
            map(_as_hashable, alternative_combos)
        )
        assert all([c in alternative_combos for c in combos])