benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 7034aa2e-a796-588b-8cbf-de18e3b61cd6

Problem

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

complete prompt

import numpy as np
import itertools
import json


def task_func(data_list, json_file_name="mean_values.json"):
    """
    Calculate the mean of the numeric values for each position in the provided data list 
    and return the results. Optionally, the results can be exported to a specified JSON file.
    
    Parameters:
    - data_list (list of tuples): List of data tuples where each tuple contains a string followed by numeric values.
    - json_file_name (str, optional): Name of the JSON file to export the results. Defaults to 'mean_values.json'.

    Requirements:
    - numpy
    - itertools
    - json

    Returns:
    - dict: A dictionary with keys in the format 'Position {i}' and values being the mean of the numeric values 
            at position i in the provided data list.

    Example:
    >>> import tempfile
    >>> json_file = tempfile.NamedTemporaryFile(delete=False)
    >>> task_func([('a', 1, 2), ('b', 2, 3), ('c', 3, 4), ('d', 4, 5), ('e', 5, 6)], json_file.name)
    {'Position 1': 3.0, 'Position 2': 4.0}
    """

instruct prompt

Calculate the mean of the numeric values for each position in the provided data list and return the results. Optionally, the results can be exported to a specified JSON file.
The function should output with:
    dict: A dictionary with keys in the format 'Position {i}' and values being the mean of the numeric values
    at position i in the provided data list.
You should write self-contained code starting with:

Code

import numpy as np
import itertools
import json
def task_func(data_list, json_file_name="mean_values.json"):

code prompt

Code

import numpy as np
import itertools
import json
def task_func(data_list, json_file_name="mean_values.json"):

entry point

task_func

libs

  • numpy
  • itertools
  • json

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