0 out of 464 challenges solved
Write a Python function `tuple_intersection` that takes two lists of tuples and returns the intersection of these tuples, considering the tuples as unordered pairs. This means that `(a, b)` is considered the same as `(b, a)`. #### Function Signature ```python [main.nopy] def tuple_intersection(list1: list, list2: list) -> set: pass ``` #### Input - `list1`: A list of tuples, where each tuple contains exactly two elements. - `list2`: Another list of tuples, where each tuple contains exactly two elements. #### Output - A set of tuples representing the intersection of the two lists, considering the tuples as unordered pairs. #### Example Usage ```python [main.nopy] list1 = [(3, 4), (5, 6), (9, 10), (4, 5)] list2 = [(5, 4), (3, 4), (6, 5), (9, 11)] print(tuple_intersection(list1, list2)) # Output: {(4, 5), (3, 4), (5, 6)} list1 = [(4, 1), (7, 4), (11, 13), (17, 14)] list2 = [(1, 4), (7, 4), (16, 12), (10, 13)] print(tuple_intersection(list1, list2)) # Output: {(4, 7), (1, 4)} ``` #### Constraints - Each tuple in the input lists will contain exactly two elements. - The elements in the tuples are hashable. - The order of elements in the tuples does not matter for comparison.
def tuple_intersection(list1: list, list2: list) -> set: """ Returns the intersection of two lists of tuples, considering tuples as unordered pairs. Args: list1 (list): The first list of tuples. list2 (list): The second list of tuples. Returns: set: A set of tuples representing the intersection. """ # Placeholder for the solution pass