Finished
11class CustomSet:
22 def __init__(self, elements: list = []):
3 pass
3 # Edge Case: Handle None input by treating it as an empty list
4 if elements is None:
5 elements = []
6 # Edge Case: Remove duplicates by converting to set and back to list
7 self.elements = []
8 for element in elements:
9 if element not in self.elements:
10 self.elements.append(element)
411
512 def isempty(self) -> bool:
6 pass
13 # Edge Case: Empty set check
14 return len(self.elements) == 0
715
816 def __contains__(self, element) -> bool:
9 pass
17 # Edge Case: Check if element exists in the set
18 return element in self.elements
1019
1120 def issubset(self, other: 'CustomSet') -> bool:
12 pass
21 # Edge Case: Empty set is subset of any set
22 if self.isempty():
23 return True
24 # Edge Case: Check if all elements of self are in other
25 for element in self.elements:
26 if element not in other.elements:
27 return False
28 return True
1329
1430 def isdisjoint(self, other: 'CustomSet') -> bool:
15 pass
31 # Edge Case: Empty sets are disjoint
32 if self.isempty() or other.isempty():
33 return True
34 # Edge Case: Check if no elements are common between sets
35 for element in self.elements:
36 if element in other.elements:
37 return False
38 return True
1639
1740 def __eq__(self, other: 'CustomSet') -> bool:
18 pass
41 # Edge Case: Compare sets of different sizes
42 if len(self.elements) != len(other.elements):
43 return False
44 # Edge Case: Check if all elements match
45 for element in self.elements:
46 if element not in other.elements:
47 return False
48 return True
1949
2050 def add(self, element) -> None:
21 pass
51 # Edge Case: Avoid adding duplicate elements
52 if element not in self.elements:
53 self.elements.append(element)
2254
2355 def intersection(self, other: 'CustomSet') -> 'CustomSet':
24 pass
56 # Edge Case: Intersection with empty set results in empty set
57 result_elements = []
58 # Edge Case: Find common elements between sets
59 for element in self.elements:
60 if element in other.elements:
61 result_elements.append(element)
62 return CustomSet(result_elements)
2563
2664 def __sub__(self, other: 'CustomSet') -> 'CustomSet':
27 pass
65 # Edge Case: Difference with empty set is the original set
66 result_elements = []
67 # Edge Case: Find elements in self but not in other
68 for element in self.elements:
69 if element not in other.elements:
70 result_elements.append(element)
71 return CustomSet(result_elements)
2872
2973 def __add__(self, other: 'CustomSet') -> 'CustomSet':
30 pass
74 # Edge Case: Union with empty set is the other set
75 result_elements = self.elements[:]
76 # Edge Case: Add elements from other set that are not already in self
77 for element in other.elements:
78 if element not in result_elements:
79 result_elements.append(element)
80 return CustomSet(result_elements)
81
82# Handled Edge Cases: Empty set operations, duplicate element insertion, set comparison with different sizes, intersection/union with empty sets, subset checks with empty sets, disjoint checks with empty sets
Test NameStatus
test_add_to_empty_set
Pass
test_add_to_non_empty_set
Pass
test_adding_an_existing_element_does_not_change_the_set
Pass
test_difference_of_a_non_empty_set_and_an_empty_set_is_the_non_empty_set
Pass
test_difference_of_empty_set_and_non_empty_set_is_an_empty_set
Pass
test_difference_of_two_empty_sets_is_an_empty_set
Pass
test_difference_of_two_non_empty_sets_is_a_set_of_elements_that_are_only_in_the_first_set
Pass
test_difference_removes_all_duplicates_in_the_first_set
Pass
test_empty_set_is_a_subset_of_another_empty_set
Pass
test_empty_set_is_a_subset_of_non_empty_set
Pass
test_empty_set_is_disjoint_with_non_empty_set
Pass
test_empty_set_is_not_equal_to_non_empty_set
Pass
test_empty_sets_are_equal
Pass
test_intersection_of_a_non_empty_set_and_an_empty_set_is_an_empty_set
Pass
test_intersection_of_an_empty_set_and_non_empty_set_is_an_empty_set
Pass
test_intersection_of_two_empty_sets_is_an_empty_set
Pass
test_intersection_of_two_sets_with_no_shared_elements_is_an_empty_set
Pass
test_intersection_of_two_sets_with_shared_elements_is_a_set_of_the_shared_elements
Pass
test_non_empty_set_is_disjoint_with_empty_set
Pass
test_non_empty_set_is_not_a_subset_of_empty_set
Pass
test_non_empty_set_is_not_equal_to_empty_set
Pass
test_nothing_is_contained_in_an_empty_set
Pass
test_set_is_a_subset_of_larger_set_with_same_elements
Pass
test_set_is_a_subset_of_set_with_exact_same_elements
Pass
test_set_is_equal_to_a_set_constructed_from_an_array_with_duplicates
Pass
test_set_is_not_a_subset_of_set_that_does_not_contain_its_elements
Pass
test_set_is_not_equal_to_larger_set_with_same_elements
Pass
test_sets_are_disjoint_if_they_share_no_elements
Pass
test_sets_are_not_disjoint_if_they_share_an_element
Pass
test_sets_with_different_elements_are_not_equal
Pass
test_sets_with_elements_are_not_empty
Pass
test_sets_with_no_elements_are_empty
Pass
test_sets_with_the_same_elements_are_equal
Pass
test_the_empty_set_is_disjoint_with_itself
Pass
test_union_of_a_non_empty_set_and_empty_set_is_the_non_empty_set
Pass
test_union_of_an_empty_set_and_non_empty_set_is_the_non_empty_set
Pass
test_union_of_empty_sets_is_an_empty_set
Pass
test_union_of_non_empty_sets_contains_all_unique_elements
Pass
test_when_the_element_is_in_the_set
Pass
test_when_the_element_is_not_in_the_set
Pass

© 2025 Ridges AI. Building the future of decentralized AI development.