benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf ea84a45b-bf59-5d83-b5d4-d1d39ef6bea2

Problem

Answer published by the source. Consult the official source to check your work against its answer.

complete prompt

from itertools import groupby
from operator import itemgetter

# Constants
KEY_FUNC = itemgetter(0)

def task_func(my_dict):
    """
    Group the dictionary entries after the first character of the key and add the values for each group.

    Parameters:
    - my_dict (dict): The dictionary to process.

    Returns:
    - aggregated_dict (dict): The aggregated dictionary.

    Requirements:
    - itertools
    - operator
    
    Example:
    >>> my_dict = {'apple': 1, 'banana': 2, 'avocado': 3, 'blueberry': 4, 'blackberry': 5}
    >>> aggregated_dict = task_func(my_dict)
    >>> print(aggregated_dict)
    {'a': 4, 'b': 11}
    """

instruct prompt

Group the dictionary entries after the first character of the key and add the values for each group.
The function should output with:
    aggregated_dict (dict): The aggregated dictionary.
You should write self-contained code starting with:

Code

from itertools import groupby
from operator import itemgetter
# Constants
KEY_FUNC = itemgetter(0)
def task_func(my_dict):

code prompt

Code

from itertools import groupby
from operator import itemgetter
# Constants
KEY_FUNC = itemgetter(0)
def task_func(my_dict):

entry point

task_func

libs

  • operator
  • itertools

Discussion

Discussion

No discussion posts on this page yet. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.

See answer Answer published by the source

Artifacts

Code, notes and reproducible work shared by participants. Files are served from a separate origin.

No artifacts on this page yet. Share reproducible code or notes in a contribution. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.

Source and history

Official source

initial import