def test_union(self): hs = HashSet(['one', 'fish', 'two', 'fish']) hs2 = HashSet(['red', 'fish', 'blue', 'fish']) hs_union = hs.union(hs2) assert hs_union.contains('red') is True assert hs_union.contains('blue') is True print(str(hs_union)) assert hs_union.contains('purple') is False
def test_union(self): set_one = [0, 1, 2, 3, 4, 5] set_two = [3, 4, 5, 6, 7, 8] hs_one = HashSet(set_one) hs_two = HashSet(set_two) assert hs_one.size() == 6 assert hs_two.size() == 6 assert hs_one.union(hs_two).size() == 9
def test_union(self): first_set = HashSet(['One', 'Two', 'Three', 'Four']) second_set = HashSet(['Red', 'Green', 'Blue']) union = first_set.union(second_set) assert union.size == 7 assert union.contains('Two') == True assert union.contains('Three') == True assert union.contains('Blue') == True assert union.contains('Purple') == False assert union.contains('Six') == False
def test_union(self): """Check if the union operation works as intended.""" hashset = HashSet() hashset.add('FUSION!') hashset.add('HA!') other_hashset = HashSet() other_hashset.add('HA!') hashset.add('FUSION!') union = hashset.union(other_hashset) assert union.size == 2 assert union.contains('FUSION!') is True assert union.contains('HA!') is True
def test_union(self): elements1 = ["hola", "adios", "test", "test", "annie"] elements2 = ["pamis", "blah", "other", "test", "hola"] hs = HashSet(elements1) other_hs = HashSet(elements2) union = hs.union(other_hs) assert union.contains("hola") == True assert union.contains("adios") == True assert union.contains("test") == True assert union.contains("annie") == True assert union.contains("pamis") == True assert union.contains("blah") == True assert union.contains("other") == True
def test_union(self): data_a = ['A', 'B', 'C'] hs_a = HashSet(data_a) data_b = ['D', 'E', 'F'] hs_b = HashSet(data_b) union_hs = hs_a.union(hs_b) assert union_hs.contains('A') == True assert union_hs.contains('B') == True assert union_hs.contains('C') == True assert union_hs.contains('D') == True assert union_hs.contains('E') == True assert union_hs.contains('F') == True assert hs_a.contains('D') == False assert hs_a.contains('E') == False assert hs_a.contains('F') == False
def solution_ok(matrix): """ Check that: - all cells of the matrix contain exactly 1 element - the union of all cells in a group has 9 elements :param list[list[HashSet]] matrix: 2D matrix representing sudoku cells :return bool: True if the sudoku is solved, else False """ for i in range(9): for j in range(9): if len(matrix[i][j]) != 1: return False groups = get_groups(matrix) for group in groups: union = HashSet() for cell in group: union = union.union(cell) if len(union) != 9: return False return True
def test_union(self): set_a = HashSet([1, 2, 3]) set_b = HashSet([4, 5, 6]) assert set_a.union(set_b).elements() == [1, 2, 3, 4, 5, 6] set_c = HashSet([1, 1, 1]) assert set_a.union(set_c).elements() == [1, 2, 3]