benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 6c53e8b6-1814-5d62-a82f-4872bbc79360

Problem

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

complete prompt

import itertools
import collections


def task_func(elements, subset_size):
    """
    Generate all 2-element subsets of a tuple and count the occurrences of each sum in the subsets.

    Returns:
    dict: A dictionary with the sums and their counts.

    Requirements:
    - itertools
    - random
    - collections
    
    
    Example:
    >>> dict(task_func((1, 2, 3, 4, 5), 2))
    {3: 1, 4: 1, 5: 2, 6: 2, 7: 2, 8: 1, 9: 1}
    """

instruct prompt

Generate all 2-element subsets of a tuple and count the occurrences of each sum in the subsets.
The function should output with:
    dict: A dictionary with the sums and their counts.
You should write self-contained code starting with:

Code

import itertools
import collections
def task_func(elements, subset_size):

code prompt

Code

import itertools
import collections
def task_func(elements, subset_size):

entry point

task_func

libs

  • collections
  • 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