benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf eca05dea-fdb9-57b5-98c7-0501005ace99

Problem

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

complete prompt

from collections import Counter
import random
import itertools

def task_func(length, count, seed=0):
    """
    Generate a number of random strings with a specified length from a fixed set of letters ('a', 'b', 'c', 'd', 'e'),
    and analyze the frequency of each letter in the generated strings.
    
    Parameters:
    - length (int): The length of each string to be generated. Should be a non-negative integer.
    - count (int): The number of random strings to generate. Should be a non-negative integer.
    - seed (int, optional): A seed for the random number generator to ensure reproducibility.
    
    Requirements:
    - collections.Counter
    - random
    - itertools
    
    Returns:
    - Counter: A collections.Counter object containing the frequency of each letter in the generated strings.
    
    Example:
    >>> task_func(5, 2, seed=1)
    Counter({'a': 3, 'd': 3, 'c': 2, 'e': 1, 'b': 1})
    >>> task_func(0, 100, seed=2)
    Counter()
    """

instruct prompt

Generate a number of random strings with a specified length from a fixed set of letters ('a', 'b', 'c', 'd', 'e'), and analyze the frequency of each letter in the generated strings.
The function should output with:
    Counter: A collections.Counter object containing the frequency of each letter in the generated strings.
You should write self-contained code starting with:

Code

from collections import Counter
import random
import itertools
def task_func(length, count, seed=0):

code prompt

Code

from collections import Counter
import random
import itertools
def task_func(length, count, seed=0):

entry point

task_func

libs

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