0 out of 464 challenges solved
Write a Python function that takes a list of tuples as input and returns a dictionary. The dictionary should map each unique tuple to the number of times it occurs in the list. The tuples in the list may not be sorted, so the function should treat tuples with the same elements in different orders as identical. #### Example Usage ```python [main.nopy] input_list = [(3, 1), (1, 3), (2, 5), (5, 2), (6, 3)] result = count_tuple_occurrences(input_list) print(result) # Output: {(1, 3): 2, (2, 5): 2, (3, 6): 1} input_list = [(4, 2), (2, 4), (3, 6), (6, 3), (7, 4)] result = count_tuple_occurrences(input_list) print(result) # Output: {(2, 4): 2, (3, 6): 2, (4, 7): 1} ```
from collections import Counter def count_tuple_occurrences(input_list): """ Count the occurrences of unique tuples in the input list. Args: input_list (list of tuples): A list containing tuples of integers. Returns: dict: A dictionary mapping each unique tuple to its count. """ # Placeholder for the solution pass