benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 8c9e9517-69b2-512c-84bd-050ca2c9899f

Problem

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

complete prompt

import random
import re

# Constants
WORD_LIST = ["sample", "text", "contains", "several", "words", "including"]

def task_func(n_sentences):
    """
    Generate a string of random sentences using a predefined word list. 
    Each sentence is guaranteed to have one period at the end, and no period within the sentence.
    The generated sentences will be concatenated into a single string, 
    with all letters in lowercase and all non-alphanumeric characters except spaces removed.

    Parameters:
    - n_sentences (int): The number of sentences to generate.

    Returns:
    - str: A string containing the generated sentences in lowercase 
         with non-alphanumeric characters removed (except for single periods ending sentences).
    
    Requirements:
    - random
    - re
    
    Example:
    >>> random.seed(42)
    >>> result = task_func(2)
    >>> print(result)
    sample sample including contains text text text including sample including. words sample words several sample sample sample text text words.
    
    Note: 
    - The actual output will vary due to the randomness of sentence generation.
    """

instruct prompt

Generate a string of random sentences using a predefined word list. Each sentence is guaranteed to have one period at the end, and no period within the sentence. The generated sentences will be concatenated into a single string, with all letters in lowercase and all non-alphanumeric characters except spaces removed.
Note that: The actual output will vary due to the randomness of sentence generation.
The function should output with:
    str: A string containing the generated sentences in lowercase
    with non-alphanumeric characters removed (except for single periods ending sentences).
You should write self-contained code starting with:

Code

import random
import re
# Constants
WORD_LIST = ["sample", "text", "contains", "several", "words", "including"]
def task_func(n_sentences):

code prompt

Code

import random
import re
# Constants
WORD_LIST = ["sample", "text", "contains", "several", "words", "including"]
def task_func(n_sentences):

entry point

task_func

libs

  • random
  • re

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