benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 63ce1bfb-6e5d-5ee7-b711-bf64d07c290b

Problem

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

complete prompt

import collections
import random

# Constants
LETTERS = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']

def task_func(n_keys, n_values):
    """
    Create a Python dictionary with a specified number of keys and values. 

    Parameters:
    n_keys (int): The number of keys to generate.
    n_values (int): The number of values for each key (consecutive integers starting from 1).

    Returns:
    dict: A Python dictionary with keys as strings and values as lists of integers.

    Note: 
    - Keys are randomly selected from a predefined list of letters, and values are consecutive integers starting from 1.
    - Due to the randomness in key selection, the actual keys in the dictionary may vary in each execution.

    Requirements:
    - collections
    - random

    Example:
    >>> random.seed(0)
    >>> task_func(3, 5)
    {'g': [1, 2, 3, 4, 5], 'a': [1, 2, 3, 4, 5]}
    >>> result = task_func(1, 5)
    >>> list(result)[0] in LETTERS
    True
    """

instruct prompt

Create a Python dictionary with a specified number of keys and values.
Note that: Keys are randomly selected from a predefined list of letters, and values are consecutive integers starting from 1. Due to the randomness in key selection, the actual keys in the dictionary may vary in each execution.
The function should output with:
    dict: A Python dictionary with keys as strings and values as lists of integers.
You should write self-contained code starting with:

Code

import collections
import random
# Constants
LETTERS = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']
def task_func(n_keys, n_values):

code prompt

Code

import collections
import random
# Constants
LETTERS = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']
def task_func(n_keys, n_values):

entry point

task_func

libs

  • collections
  • random

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