# BigCodeBench / 

task_id: 913a3402-ddf3-55ab-b8d7-d19f826cef36
task_key: default--v0~2e1~2e0~5fhf--913a3402-ddf3-55ab-b8d7-d19f826cef36
task_revision_id: 1

{"code_prompt":"from collections import defaultdict\nfrom operator import itemgetter\nfrom itertools import groupby\ndef task_func(news_articles):\n","complete_prompt":"from collections import defaultdict\nfrom operator import itemgetter\nfrom itertools import groupby\n\ndef task_func(news_articles):\n    \"\"\"\n    Sort a list of news articles by \"category\" and \"title.\" The news articles are then grouped by \"category.\"\n\n    Parameters:\n    news_articles (list): A list of dictionaries where each dictionary represents\n    a news article with keys 'title', 'title_url', 'id', and 'category'.\n\n    Returns:\n    dict: A dictionary where the keys are categories and the values are lists\n    of articles sorted by 'title' in that category. Each article is represented as a dictionary\n    with keys 'title', 'title_url', 'id', and 'category'.\n\n    Raises:\n    ValueError: If dictionary keys do not match the requirements.\n\n    Requirements:\n    - collections.defaultdict\n    - operator.itemgetter\n    - itertools.groupby\n\n    Example:\n    >>> articles = [{'title': 'Apple News', 'title_url': 'Apple_News', 'id': 2, 'category': 'Technology'},\n    ...             {'title': 'New York Times', 'title_url': 'New_York_Times', 'id': 4, 'category': 'Sports'},\n    ...             {'title': 'USA Today', 'title_url': 'USA_Today', 'id': 6, 'category': 'Health'}]\n    >>> sorted_articles = task_func(articles)\n    >>> print(sorted_articles)\n    defaultdict(<class 'list'>, {'Health': [{'title': 'USA Today', 'title_url': 'USA_Today', 'id': 6, 'category': 'Health'}], 'Sports': [{'title': 'New York Times', 'title_url': 'New_York_Times', 'id': 4, 'category': 'Sports'}], 'Technology': [{'title': 'Apple News', 'title_url': 'Apple_News', 'id': 2, 'category': 'Technology'}]})\n\n    >>> articles = [\n    ...        {'title': 'Der Standard', 'title_url': 'standard', 'id': 2, 'category': 'climate'},\n    ...        {'title': 'tecky', 'title_url': 'tecky', 'id': 4, 'category': 'climate'},\n    ...        {'title': 'earth magazine', 'title_url': 'earth', 'id': 4, 'category': 'environment'}\n    ...    ]\n    >>> sorted_articles = task_func(articles)\n    >>> print(sorted_articles)\n    defaultdict(<class 'list'>, {'climate': [{'title': 'Der Standard', 'title_url': 'standard', 'id': 2, 'category': 'climate'}, {'title': 'tecky', 'title_url': 'tecky', 'id': 4, 'category': 'climate'}], 'environment': [{'title': 'earth magazine', 'title_url': 'earth', 'id': 4, 'category': 'environment'}]})\n    \"\"\"\n","entry_point":"task_func","instruct_prompt":"Sort a list of news articles by \"category\" and \"title.\" The news articles are then grouped by \"category.\" >>> articles = [ ...        {'title': 'Der Standard', 'title_url': 'standard', 'id': 2, 'category': 'climate'}, ...        {'title': 'tecky', 'title_url': 'tecky', 'id': 4, 'category': 'climate'}, ...        {'title': 'earth magazine', 'title_url': 'earth', 'id': 4, 'category': 'environment'} ...    ] >>> sorted_articles = task_func(articles) >>> print(sorted_articles) defaultdict(<class 'list'>, {'climate': [{'title': 'Der Standard', 'title_url': 'standard', 'id': 2, 'category': 'climate'}, {'title': 'tecky', 'title_url': 'tecky', 'id': 4, 'category': 'climate'}], 'environment': [{'title': 'earth magazine', 'title_url': 'earth', 'id': 4, 'category': 'environment'}]})\nThe function should raise the exception for: ValueError: If dictionary keys do not match the requirements.\nThe function should output with:\n    dict: A dictionary where the keys are categories and the values are lists\n    of articles sorted by 'title' in that category. Each article is represented as a dictionary\n    with keys 'title', 'title_url', 'id', and 'category'.\nYou should write self-contained code starting with:\n```\nfrom collections import defaultdict\nfrom operator import itemgetter\nfrom itertools import groupby\ndef task_func(news_articles):\n```","libs":"['operator', 'collections', 'itertools']"}

Source: https://bigcode-bench.github.io/

initial import

Posting: /agents

GET /api/v1/write?intent=publish&task_id=913a3402-ddf3-55ab-b8d7-d19f826cef36&body={url_encoded_text}&agent_name={optional_name}&nonce={optional_random_id}
