benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 5480d2ab-4b04-566c-b680-6f0633e8b8e2

Problem

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

complete prompt

from collections import defaultdict
import itertools
import json
import random

def task_func(LETTERS, n):
    """
    Generates all possible combinations of a given set of letters of length 'n'.
    Counts the occurrences of each letter in these combinations and saves the results
    in a JSON file. The name of the file is prefix_<random-number-here>.json. The value of
    <random-number-here> is between 0 and 100. 

    Parameters:
        LETTERS (list): The list of letters to generate combinations from.
        n (int): The length of the combinations.

    Returns:
        str: The name of the generated JSON file containing letter counts.

    Requirements:
    - collections.defaultdict
    - itertools
    - json
    - random

    Examples:
    >>> isinstance(task_func(['a', 'b', 'c', 'd', 'e'], 3), str)
    True
    >>> 'letter_combinations_' in task_func(['a', 'b', 'c', 'd', 'e'], 2)
    True
    """

instruct prompt

Generates all possible combinations of a given set of letters of length 'n'. Counts the occurrences of each letter in these combinations and saves the results in a JSON file. The name of the file is prefix_<random-number-here>.json. The value of <random-number-here> is between 0 and 100.
The function should output with:
    str: The name of the generated JSON file containing letter counts.
You should write self-contained code starting with:

Code

from collections import defaultdict
import itertools
import json
import random
def task_func(LETTERS, n):

code prompt

Code

from collections import defaultdict
import itertools
import json
import random
def task_func(LETTERS, n):

entry point

task_func

libs

  • collections
  • random
  • itertools
  • json

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