benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 2b0a95a2-16f1-55a2-8c38-c02837b5346a

Problem

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

complete prompt

import random
import string
import pandas as pd


def task_func(n_rows=1000):
    """
    Generate a histogram of the frequency of the top 30 unique random 3-letter strings.
    The function creates random strings, each consisting of 3 letters from the lowercase English alphabet.
    It then plots a histogram showing the frequencies of the top 30 most common strings among the generated set.

    Parameters:
    - n_rows (int): Number of random 3-letter strings to generate.
    Must be positive. Default is 1000.

    Returns:
    - ax (matplotlib.axes.Axes): A Matplotlib Axes object containing the histogram.
    Each bar represents one of the top 30 most frequent 3-letter strings.

    Raises:
    - ValueError: If `n_rows` is less than or equal to 0.

    Requirements:
    - random
    - string
    - pandas
    
    Example:
    >>> ax = task_func(1000)
    >>> ax.get_title()
    'Top 30 Frequencies of Random 3-Letter Strings'
    """

instruct prompt

Generate a histogram of the frequency of the top 30 unique random 3-letter strings. The function creates random strings, each consisting of 3 letters from the lowercase English alphabet. It then plots a histogram showing the frequencies of the top 30 most common strings among the generated set.
The function should raise the exception for: ValueError: If `n_rows` is less than or equal to 0.
The function should output with:
    ax (matplotlib.axes.Axes): A Matplotlib Axes object containing the histogram.
    Each bar represents one of the top 30 most frequent 3-letter strings.
You should write self-contained code starting with:

Code

import random
import string
import pandas as pd
def task_func(n_rows=1000):

code prompt

Code

import random
import string
import pandas as pd
def task_func(n_rows=1000):

entry point

task_func

libs

  • pandas
  • 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