benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 6c2db582-eee7-5904-8f27-891514d1e65b

Problem

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

complete prompt

import numpy as np
import random
from scipy import stats


def task_func(list_of_lists, size=5, seed=0):
    """
    Calculate the mean, median, and mode of values in a list of lists.
    If a list is empty, fill it with SIZE (default: 5) random integers between 0 and 100, 
    and then calculate the statistics.
    
    Parameters:
    list_of_lists (list): The list of lists.
    size (int, Optional): The number of random integers to generate. Default is 5.
    seed (int, Optional): Seed value for random number generation. Default is 0.
    
    Returns:
    dict: A dictionary with the mean, median, and mode of the values.
    
    Requirements:
    - numpy
    - random
    - scipy.stats
    
    Example:
    >>> task_func([[1, 2, 3], [], [4, 5, 6]])
    {'mean': 23.454545454545453, 'median': 5.0, 'mode': array([5])}
    """

instruct prompt

Calculate the mean, median, and mode of values in a list of lists. If a list is empty, fill it with SIZE (default: 5) random integers between 0 and 100, and then calculate the statistics.
The function should output with:
    dict: A dictionary with the mean, median, and mode of the values.
You should write self-contained code starting with:

Code

import numpy as np
import random
from scipy import stats
def task_func(list_of_lists, size=5, seed=0):

code prompt

Code

import numpy as np
import random
from scipy import stats
def task_func(list_of_lists, size=5, seed=0):

entry point

task_func

libs

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