benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 83419c34-a941-5e29-b38f-34b3eed792f3

Problem

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

complete prompt

import random
from scipy import stats

def task_func(animals, mean):
    """
    Simulates sales in a pet shop based on a randomly determined number of customers.
    Each customer randomly buys one type of animal from the specified list of animals.
    The function displays and returns a summary of the sales, where the number of customers 
    follows a Poisson distribution with the specified mean (mu).

    Parameters:
        animals (list of str): A list of animal types available for sale.

    Returns:
        dict: A dictionary with animal types as keys and the number of sales as values.

    Requirements:
    - random
    - scipy.stats

    Examples:
    >>> ANIMALS = ['Dog', 'Cat', 'Bird', 'Fish', 'Hamster']
    >>> sales = task_func(ANIMALS, 120)
    >>> isinstance(sales, dict)
    True
    >>> all(animal in ANIMALS for animal in sales.keys())
    True
    >>> sum(sales.values()) >= 0  # sum of sales should be non-negative
    True
    """

instruct prompt

Simulates sales in a pet shop based on a randomly determined number of customers. Each customer randomly buys one type of animal from the specified list of animals. The function displays and returns a summary of the sales, where the number of customers follows a Poisson distribution with the specified mean (mu).
The function should output with:
    dict: A dictionary with animal types as keys and the number of sales as values.
You should write self-contained code starting with:

Code

import random
from scipy import stats
def task_func(animals, mean):

code prompt

Code

import random
from scipy import stats
def task_func(animals, mean):

entry point

task_func

libs

  • random
  • scipy

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