benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 294bb299-1eea-54d2-b069-63fd78340b6b

Problem

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

complete prompt

import itertools
import random

def task_func(t, n):
    """
    Generate all combinations from a tuple with length n and return a random combination of length n.
    
    Parameters:
    - t (tuple): The tuple.
    - n (int): The length of the combinations.
    
    Returns:
    - tuple: A combination of the input tuple.

    Requirements:
    - itertools
    - random
    
    Example:
    >>> random.seed(42)
    >>> task_func((1, 2, 3, 4), 2)
    (3, 4)
    """

instruct prompt

Generate all combinations from a tuple with length n and return a random combination of length n.
The function should output with:
    tuple: A combination of the input tuple.
You should write self-contained code starting with:

Code

import itertools
import random
def task_func(t, n):

code prompt

Code

import itertools
import random
def task_func(t, n):

entry point

task_func

libs

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