benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 6869fadb-9ac5-54b9-957d-8245d595cec5

Problem

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

complete prompt

import matplotlib.pyplot as plt
import random

# Constants
COLORS = ['#00bfbf', '#000000', '#0000ff']
def task_func(number_list, bins):
    """
    Create a histogram subplot of a list of numbers.

    Parameters:
    - number_list (list): A list of numeric values to be plotted.
    - bins (int or sequence): If an integer, the number of histogram bins. 
      If a sequence, defines the bin edges.

    Returns:
    matplotlib.axes._axes.Axes: The axes object representing the histogram plot.

    Note:
    - This function generates a histogram plot using Matplotlib.
    - The plot title is set to 'Histogram'.
    - The x-axis label is set to 'Number'.
    - The y-axis label is set to 'Frequency'.
    - The color of the histogram bars is randomly selected from a predefined set of colors.


    Requirements:
    - matplotlib.pyplot
    - random

    Example:
    >>> random.seed(0)
    >>> number_list = [1, 2, 2, 3, 3, 3, 4, 4, 5]
    >>> bins = 5
    >>> ax = task_func(number_list, bins)
    >>> ax.patches[0].get_height()
    1.0
    >>> ax.patches[2].get_height() > ax.patches[0].get_height()
    True
    >>> plt.close()
    """

instruct prompt

Create a histogram subplot of a list of numbers.
Note that: This function generates a histogram plot using Matplotlib. The plot title is set to 'Histogram'. The x-axis label is set to 'Number'. The y-axis label is set to 'Frequency'. The color of the histogram bars is randomly selected from a predefined set of colors.
The function should output with:
    matplotlib.axes._axes.Axes: The axes object representing the histogram plot.
You should write self-contained code starting with:

Code

import matplotlib.pyplot as plt
import random
# Constants
COLORS = ['#00bfbf', '#000000', '#0000ff']
def task_func(number_list, bins):

code prompt

Code

import matplotlib.pyplot as plt
import random
# Constants
COLORS = ['#00bfbf', '#000000', '#0000ff']
def task_func(number_list, bins):

entry point

task_func

libs

  • random
  • matplotlib

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