benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 26214b59-80a9-5e4a-9604-fe00a5f33a0e

Problem

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

complete prompt

from collections import Counter
import random
import matplotlib.pyplot as plt


def task_func(num_rolls, num_dice, plot_path=None, random_seed=0):
    """Simulate rolling a certain number of a standard six-sided dice several times, then
    identify and display the distribution of the sums of the dice rolls in a bar plot.

    Parameters:
    - num_rolls (int): The number of times to roll the dice.
    - num_dice (int): The number of dice to roll each time.
    - plot_path (str, optional): Path to save the generated plot. If not provided, plot is not saved.
    - random_seed (int): Random seed for reproducibility. Defaults to 0.

    Returns:
    tuple: A tuple containing the following elements:
        - Counter: A Counter object with the count of each possible sum.
        - Axes: A matplotlib Axes object representing the bar plot of the Distribution of Dice Roll Sums,
                with Sum of Dice Roll on the x-axis and count on the y-axis.

    Requirements:
    - collections.Counter
    - random
    - matplotlib.pyplot

    Example:
    >>> result, ax = task_func(10000, 2, 'output.png')
    >>> type(result)
    <class 'collections.Counter'>
    >>> type(ax)
    <class 'matplotlib.axes._axes.Axes'>
    """

instruct prompt

Simulate rolling a certain number of a standard six-sided dice several times, then identify and display the distribution of the sums of the dice rolls in a bar plot.
The function should output with:
    tuple: A tuple containing the following elements:
    Counter: A Counter object with the count of each possible sum.
    Axes: A matplotlib Axes object representing the bar plot of the Distribution of Dice Roll Sums,
    with Sum of Dice Roll on the x-axis and count on the y-axis.
You should write self-contained code starting with:

Code

from collections import Counter
import random
import matplotlib.pyplot as plt
def task_func(num_rolls, num_dice, plot_path=None, random_seed=0):

code prompt

Code

from collections import Counter
import random
import matplotlib.pyplot as plt
def task_func(num_rolls, num_dice, plot_path=None, random_seed=0):

entry point

task_func

libs

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