diff --git a/common_tags.py b/common_tags.py new file mode 100644 index 0000000..8cbb836 --- /dev/null +++ b/common_tags.py @@ -0,0 +1,13 @@ +from __future__ import annotations + + +def find_common_tags(articles: list[dict[str, list[str]]]) -> set[str]: + if not articles: + return set() + + # Using set intersection to find common tags + common_tags = set(articles[0]["tags"]) + for article in articles[1:]: + common_tags.intersection_update(article["tags"]) + + return common_tags