benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf f88597b0-5869-5818-bb1b-04e82887950b

Problem

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

complete prompt

import heapq
import random


def task_func(list_length:5, k:int):
    """
    Find the k largest numbers in a random-generated list using heapq.

    Parameters:
    list_length (int): The length of the randomly generated list of integers.
    k (int): The number of largest elements to find.

    Returns:
    tuple: A tuple containing two lists: 
        - list[int]: The randomly generated list of integers with the specified length.
        - list[int]: The k largest numbers found using heapq.

    Requirements:
    - heapq
    - random

    Example:
    >>> random.seed(0)
    >>> rand_list, top_k = task_func(5, 3)
    >>> top_k[0] in rand_list
    True
    """

instruct prompt

Find the k largest numbers in a random-generated list using heapq.
The function should output with:
    tuple: A tuple containing two lists:
    list[int]: The randomly generated list of integers with the specified length.
    list[int]: The k largest numbers found using heapq.
You should write self-contained code starting with:

Code

import heapq
import random
def task_func(list_length:5, k:int):

code prompt

Code

import heapq
import random
def task_func(list_length:5, k:int):

entry point

task_func

libs

  • random
  • heapq

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