benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 99ad3f9c-623e-5f70-929b-ce5635b997a9

Problem

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

complete prompt

import random
import string
from collections import Counter

def task_func(num_strings, string_length):
    """
    Creates a list of random strings, each of a specified length, and counts the frequency
    of each character across all strings. The function then returns the characters
    and their frequencies sorted by frequency in descending order.
    The random strings are composed of ASCII lowercase characters.

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

    Requirements:
    - random
    - string
    - collections.Counter

    Returns:
        list of tuple: A list of tuples where each tuple contains a character and its count,
                       sorted by count in descending order.

    Examples:
    >>> type(task_func(1000, 5)) == list
    True
    >>> all(isinstance(pair, tuple) and len(pair) == 2 for pair in task_func(1000, 5))
    True
    """

instruct prompt

Creates a list of random strings, each of a specified length, and counts the frequency of each character across all strings. The function then returns the characters and their frequencies sorted by frequency in descending order. The random strings are composed of ASCII lowercase characters.
The function should output with:
    list of tuple: A list of tuples where each tuple contains a character and its count,
    sorted by count in descending order.
You should write self-contained code starting with:

Code

import random
import string
from collections import Counter
def task_func(num_strings, string_length):

code prompt

Code

import random
import string
from collections import Counter
def task_func(num_strings, string_length):

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