benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 28e51e05-5772-5a9c-a792-0e983f797e4d

Problem

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

complete prompt

import random
import string
import collections

# Constants
VALID_CHARACTERS = string.ascii_letters + string.digits

def task_func(n_strings, string_length):
    """
    Generate n random strings of a specified length, count the frequency of each character across all strings, and return the result as a dictionary.

    Parameters:
    - n_strings (int): The number of random strings to generate.
    - string_length (int): The length of each random string.

    Returns:
    - dict: A dictionary containing character counts with characters as keys and their frequencies as values.

    Requirements:
    - random
    - string
    - collections

    Constants:
    - VALID_CHARACTERS: A string containing all valid characters (ASCII letters and digits) that can be used in the random strings.

    Example:
    >>> random.seed(42)
    >>> task_func(2, 3)
    {'O': 1, 'h': 1, 'b': 1, 'V': 1, 'r': 1, 'p': 1}
    """

instruct prompt

Generate n random strings of a specified length, count the frequency of each character across all strings, and return the result as a dictionary. Constants: - VALID_CHARACTERS: A string containing all valid characters (ASCII letters and digits) that can be used in the random strings.
The function should output with:
    dict: A dictionary containing character counts with characters as keys and their frequencies as values.
You should write self-contained code starting with:

Code

import random
import string
import collections
# Constants
VALID_CHARACTERS = string.ascii_letters + string.digits
def task_func(n_strings, string_length):

code prompt

Code

import random
import string
import collections
# Constants
VALID_CHARACTERS = string.ascii_letters + string.digits
def task_func(n_strings, string_length):

entry point

task_func

libs

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