benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 56033861-cbba-5ac8-a404-74af7c0e00d6

Problem

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

complete prompt

from itertools import combinations
import pandas as pd


def task_func(number_list, element):
    """
    Find all unique combinations of 3 numbers from a list that add up to a certain element.

    If the number_list is empty, or there is no combination that adds up to the element,
    an empty dataframe is returned.
    

    Parameters:
    number_list (list): The list of numbers.
    element (int): The number to which the combination of 3 numbers should add up.

    Returns:
    Pandas DataFrame: A pandas Dataframe with the column 'Combinations',
         where each row contains a tuple containing a unique combination of 3 numbers that add up to the element.

    Requirements:
    - itertools
    - pandas:

    Example:
    >>> result = task_func([1, 2, 3, 4, 5], 6)
    >>> print(result)    
      Combinations
    0    (1, 2, 3)

    >>> result = task_func([-1, 1, 0, -2, 2, 3], 0)
    >>> print(result) 
      Combinations
    0  (-1, -2, 3)
    1   (-1, 1, 0)
    2   (0, -2, 2)

    >>> result = task_func([], 0)
    >>> print(result)
    Empty DataFrame
    Columns: [Combinations]
    Index: []
    """

instruct prompt

Find all unique combinations of 3 numbers from a list that add up to a certain element. If the number_list is empty, or there is no combination that adds up to the element, an empty dataframe is returned. >>> result = task_func([-1, 1, 0, -2, 2, 3], 0) >>> print(result) Combinations 0  (-1, -2, 3) 1   (-1, 1, 0) 2   (0, -2, 2) >>> result = task_func([], 0) >>> print(result) Empty DataFrame Columns: [Combinations] Index: []
The function should output with:
    Pandas DataFrame: A pandas Dataframe with the column 'Combinations',
    where each row contains a tuple containing a unique combination of 3 numbers that add up to the element.
You should write self-contained code starting with:

Code

from itertools import combinations
import pandas as pd
def task_func(number_list, element):

code prompt

Code

from itertools import combinations
import pandas as pd
def task_func(number_list, element):

entry point

task_func

libs

  • 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