benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf c2063063-94ef-5fa3-93f2-61aa4e973412

Problem

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

complete prompt

import string
import random



def task_func(length, random_seed=None):
    """
    Generate a random string of a given length, with each character being either
    a parenthesis (from the set "(){}[]") 
    or a lowercase English character.
    For function uses a optional random_seed when sampling characters.

    Parameters:
    length (int): The length of the string to generate.
    random_seed (int): Random seed for rng. Used in picking random characters.
                       Defaults to None.

    Returns:
    str: The generated string.

    Requirements:
    - string
    - random

    Note: The function uses the internal string constant BRACKETS for 
          definition of the bracket set.

    Example:
    >>> string = task_func(10, random_seed=1)
    >>> print(string)
    ieqh]{[yng
    
    >>> string = task_func(34, random_seed=42)
    >>> print(string)
    hbrpoigf)cbfnobm(o{rak)vrjnvgfygww

    >>> string = task_func(23, random_seed=1)
    >>> print(string)
    ieqh]{[yng]by)a{rogubbb
    """

instruct prompt

Generate a random string of a given length, with each character being either a parenthesis (from the set "(){}[]") or a lowercase English character. For function uses a optional random_seed when sampling characters. >>> string = task_func(34, random_seed=42) >>> print(string) hbrpoigf)cbfnobm(o{rak)vrjnvgfygww >>> string = task_func(23, random_seed=1) >>> print(string) ieqh]{[yng]by)a{rogubbb
Note that: The function uses the internal string constant BRACKETS for definition of the bracket set.
The function should output with:
    str: The generated string.
You should write self-contained code starting with:

Code

import string
import random
def task_func(length, random_seed=None):

code prompt

Code

import string
import random
def task_func(length, random_seed=None):

entry point

task_func

libs

  • random
  • string

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