benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 87fdfb58-0096-507f-9990-d94dd2c681d7

Problem

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

complete prompt

import numpy as np
import random

def task_func(MIN_WORDS, MAX_WORDS, WORDS_POOL):
    """
    Generates a palindrome sentence using random words from a specified pool. The sentence's length is randomly
    chosen between a minimum (MIN_WORDS) and maximum (MAX_WORDS) number of words. The function ensures that the
    sentence reads the same forwards and backwards.

    Parameters:
    MIN_WORDS (int): Minimum number of words in the palindrome sentence.
    MAX_WORDS (int): Maximum number of words in the palindrome sentence.
    WORDS_POOL (list): List of words to choose from for generating the palindrome.

    Returns:
    str: The generated palindrome sentence.

    Requirements:
    - numpy
    - random

    Examples:
    Generate a palindrome sentence and check if it's indeed a palindrome.
    >>> MIN_WORDS, MAX_WORDS, WORDS_POOL = 3, 10, ['apple', 'banana', 'racecar', 'world', 'level', 'madam', 'radar', 'rotor']
    >>> sentence = task_func(MIN_WORDS, MAX_WORDS, WORDS_POOL)
    >>> re_sentence = " ".join(sentence.split()[::-1])
    >>> sentence == re_sentence
    True

    Check if the generated sentence length is within the specified range.
    >>> sentence = task_func(MIN_WORDS, MAX_WORDS, WORDS_POOL)
    >>> MIN_WORDS <= len(sentence.split()) <= MAX_WORDS
    True
    """

instruct prompt

Generates a palindrome sentence using random words from a specified pool. The sentence's length is randomly chosen between a minimum (MIN_WORDS) and maximum (MAX_WORDS) number of words. The function ensures that the sentence reads the same forwards and backwards. Check if the generated sentence length is within the specified range. >>> sentence = task_func(MIN_WORDS, MAX_WORDS, WORDS_POOL) >>> MIN_WORDS <= len(sentence.split()) <= MAX_WORDS True
The function should output with:
    str: The generated palindrome sentence.
You should write self-contained code starting with:

Code

import numpy as np
import random
def task_func(MIN_WORDS, MAX_WORDS, WORDS_POOL):

code prompt

Code

import numpy as np
import random
def task_func(MIN_WORDS, MAX_WORDS, WORDS_POOL):

entry point

task_func

libs

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