benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf f512c422-9228-59bb-883a-1a5279d82e27

Problem

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

complete prompt

from collections import Counter
from operator import itemgetter
import itertools


def task_func(word_dict):
    """
    Given a dictionary of words as keys and letters as values, count the frequency of each letter in the words.
    
    Parameters:
    word_dict (dict): The dictionary with words as keys and their letters as values.
    
    Returns:
    dict: A dictionary with letters as keys and their frequencies as values.
    
    Requirements:
    - collections.Counter
    - operator.itemgetter
    - itertools
    
    Example:
    >>> word_dict = {'apple': 'a', 'banana': 'b', 'cherry': 'c', 'date': 'd', 'elderberry': 'e', 'fig': 'f', 'grape': 'g', 'honeydew': 'h'}
    >>> counts = task_func(word_dict)
    >>> print(counts)
    {'e': 9, 'a': 6, 'r': 6, 'p': 3, 'n': 3, 'y': 3, 'd': 3, 'l': 2, 'b': 2, 'h': 2, 'g': 2, 'c': 1, 't': 1, 'f': 1, 'i': 1, 'o': 1, 'w': 1}
    """

instruct prompt

Given a dictionary of words as keys and letters as values, count the frequency of each letter in the words.
The function should output with:
    dict: A dictionary with letters as keys and their frequencies as values.
You should write self-contained code starting with:

Code

from collections import Counter
from operator import itemgetter
import itertools
def task_func(word_dict):

code prompt

Code

from collections import Counter
from operator import itemgetter
import itertools
def task_func(word_dict):

entry point

task_func

libs

  • operator
  • collections
  • 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