benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 83aef2d8-4517-5cef-a3c7-5827ab48ea0e

Problem

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

complete prompt

import random
import string
from matplotlib import pyplot as plt


def task_func(elements, seed=100):
    """
    Format each string in the given list "elements" into a pattern "% {0}%", 
    where {0} is a randomly generated alphanumeric string of length 5. Additionally,
    return the plot axes of an histogram of the occurrence of each character across 
    all the strings and a dictionary containing the count of each character in all 
    the formatted strings.
    
    Parameters:
    elements (List[str]): A list of string elements to be formatted.
    seed (int, Optional): The seed for the random number generator. Defaults to 100.
    
    Returns:
    List[str]: A list of elements formatted with random patterns.
    plt.Axes: The axes object of the histogram plot.
    dict: A dictionary containing the count of each character in the formatted strings.
    
    Requirements:
    - random
    - string
    - matplotlib.pyplot
    
    Example:
    >>> patterns, ax, counts = task_func(['abc', 'def'])
    >>> patterns
    ['% jCVRT%', '% AXHeC%']
    >>> counts
    {'%': 4, ' ': 2, 'j': 1, 'C': 2, 'V': 1, 'R': 1, 'T': 1, 'A': 1, 'X': 1, 'H': 1, 'e': 1}
    """

instruct prompt

Format each string in the given list "elements" into a pattern "% {0}%", where {0} is a randomly generated alphanumeric string of length 5. Additionally, return the plot axes of an histogram of the occurrence of each character across all the strings and a dictionary containing the count of each character in all the formatted strings.
The function should output with:
    List[str]: A list of elements formatted with random patterns.
    plt.Axes: The axes object of the histogram plot.
    dict: A dictionary containing the count of each character in the formatted strings.
You should write self-contained code starting with:

Code

import random
import string
from matplotlib import pyplot as plt
def task_func(elements, seed=100):

code prompt

Code

import random
import string
from matplotlib import pyplot as plt
def task_func(elements, seed=100):

entry point

task_func

libs

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