benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf aff9d1ef-b239-5008-8864-6fe15e2dbdb0

Problem

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

complete prompt

import itertools
import math
from pandas import Series


def task_func(elements, subset_size, top_n=2):
    """
    Generate all subsets of a given size from a tuple and calculate the product of the sums of the subsets. Additionally, 
    return the top_n sums of the subsets. If the subset size is larger than the tuple length, return 1. If the subset size is 0,
    return 1.

    Parameters:
    - elements (tuple): A tuple of elements to create subsets from.
    - subset_size (int): The size of the subsets to be generated.
    - top_n (int, Optional): The number of top subsets to return. Defaults to None.

    Returns:
    int: The product of the sums of the subsets.
    list: The top_n sums of the subsets as a pandas Series.


    Requirements:
    - itertools
    - math
    
    Example:
    >>> prod, sums = task_func((1, 2, 3), 2)
    >>> prod
    60
    >>> list(sums)
    [5, 4]
    """

instruct prompt

Generate all subsets of a given size from a tuple and calculate the product of the sums of the subsets. Additionally, return the top_n sums of the subsets. If the subset size is larger than the tuple length, return 1. If the subset size is 0, return 1.
The function should output with:
    int: The product of the sums of the subsets.
    list: The top_n sums of the subsets as a pandas Series.
You should write self-contained code starting with:

Code

import itertools
import math
from pandas import Series
def task_func(elements, subset_size, top_n=2):

code prompt

Code

import itertools
import math
from pandas import Series
def task_func(elements, subset_size, top_n=2):

entry point

task_func

libs

  • math
  • pandas
  • itertools

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