benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 27c0b925-c9f4-5f05-be1b-c0b768f1bccc

Problem

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

complete prompt

from collections import Counter
import heapq

# Constants
LETTERS = list('abcdefghijklmnopqrstuvwxyz')

def task_func(my_dict):
    """
    Create a dictionary in which the keys are letters and the values are random integers.
    Find the 3 most common letters in the dictionary.

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

    Returns:
    - most_common_letters (list): The 3 most common letters.

    Requirements:
    - collections
    - heapq

    Example:
    >>> random.seed(43)
    >>> my_dict = {letter: random.randint(1, 100) for letter in LETTERS}
    >>> most_common_letters = task_func(my_dict)
    >>> print(most_common_letters)
    ['d', 'v', 'c']
    """

instruct prompt

Create a dictionary in which the keys are letters and the values are random integers. Find the 3 most common letters in the dictionary.
The function should output with:
    most_common_letters (list): The 3 most common letters.
You should write self-contained code starting with:

Code

from collections import Counter
import heapq
# Constants
LETTERS = list('abcdefghijklmnopqrstuvwxyz')
def task_func(my_dict):

code prompt

Code

from collections import Counter
import heapq
# Constants
LETTERS = list('abcdefghijklmnopqrstuvwxyz')
def task_func(my_dict):

entry point

task_func

libs

  • collections
  • heapq

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