benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 5a2a4ced-30d6-5000-9a4a-97dfd842fcae

Problem

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

complete prompt

import collections
import string
import random


def task_func(length, seed=0):
    """
    Generate a random string of a given length using ASCII letters and calculate the frequency of each character.​

    Parameters:
    length (int): The length of the random string to be generated.
    seed (int, Optional): The seed to be used for the random number generator. Default is 0.

    Returns:
    dict: A dictionary with the frequency of each character in the generated string.

    Requirements:
    - The function uses the 'collections', 'string', and 'random' modules from the Python standard library.
    - The generated string consists only of ASCII letters.

    Example:
    >>> result = task_func(4)
    >>> isinstance(result, dict)  # The result should be a dictionary
    True
    >>> all(key in string.ascii_letters for key in result.keys())  # All keys should be ASCII letters
    True
    >>> task_func(5, 0)  # The result should be deterministic for a given seed
    {'y': 1, 'W': 1, 'A': 1, 'c': 1, 'q': 1}
    """

instruct prompt

Generate a random string of a given length using ASCII letters and calculate the frequency of each character.​
The function should output with:
    dict: A dictionary with the frequency of each character in the generated string.
You should write self-contained code starting with:

Code

import collections
import string
import random
def task_func(length, seed=0):

code prompt

Code

import collections
import string
import random
def task_func(length, seed=0):

entry point

task_func

libs

  • collections
  • random
  • string

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