benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 91420c3f-ae88-5ee4-bee7-d0dfa8b1aec2

Problem

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

complete prompt

import bisect
import random

def task_func(num, list_length = 5, min_value = 0, max_value = 0):
    """
    Insert a number into a randomly generated sorted list and return the new sorted list.

    Parameters:
    num (int): The integer number to insert.
    list_length (int): The length of the randomly generated list of integers.
    min_value (int): The minimum value for randomly generated integers.
    max_value (int): The maximum value for randomly generated integers.

    Returns:
    tuple: A tuple containing two lists: 
        list[int]: The randomly generated list of integers with the specified length.
        list[int]: A new sorted list containing the original elements and the inserted number.
    
    Requirements:
    - bisect
    - random

    Example:
    >>> random.seed(0)
    >>> task_func(4, 5, 100, 100)
    ([100, 100, 100, 100, 100], [4, 100, 100, 100, 100, 100])
    >>> task_func(15, 0, 10, 20)
    ([], [15])
    """

instruct prompt

Insert a number into a randomly generated sorted list and return the new sorted list.
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]: A new sorted list containing the original elements and the inserted number.
You should write self-contained code starting with:

Code

import bisect
import random
def task_func(num, list_length = 5, min_value = 0, max_value = 0):

code prompt

Code

import bisect
import random
def task_func(num, list_length = 5, min_value = 0, max_value = 0):

entry point

task_func

libs

  • bisect
  • random

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