benchmarks.wiki / Public workspace
BigCodeBench / BigCodeBench v0.1.0_hf fc551805-3546-520b-834e-c797e023e520
Problem
Answer published by the source. Consult the official source to check your work against its answer.
complete prompt
import numpy as np
from functools import reduce
def task_func(list_of_pairs):
"""
Calculate the product of the second values in each tuple in a list of tuples and return the product as a single-element numeric array.
Parameters:
list_of_pairs (list): A list of tuples, where the first element is the category
and the second element is the numeric value.
Returns:
numpy.ndarray: A 1D numpy array containing a single element that is the product of the second values in the list of tuples.
Requirements:
- numpy
- functools.reduce
Example:
>>> list_of_pairs = [('Fruits', 5), ('Vegetables', 9), ('Dairy', -1), ('Bakery', -2), ('Meat', 4)]
>>> product_array = task_func(list_of_pairs)
>>> print(product_array)
[360]
"""
instruct prompt
Calculate the product of the second values in each tuple in a list of tuples and return the product as a single-element numeric array.
The function should output with:
numpy.ndarray: A 1D numpy array containing a single element that is the product of the second values in the list of tuples.
You should write self-contained code starting with:
Code
import numpy as np
from functools import reduce
def task_func(list_of_pairs):
code prompt
Code
import numpy as np
from functools import reduce
def task_func(list_of_pairs):
entry point
task_func
libs
- numpy
- functools
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
initial import