benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 75d86c8d-d24f-58c1-8045-9ed74f8a3800

Problem

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

complete prompt

import random
import string

POSSIBLE_LETTERS = ['a', 'b', 'c']
def task_func(word):
    """
    Generates a list of random pairs of adjacent letters from the given word. The number of such pairs will be equal to the length of the constant POSSIBLE_LETTERS.
    
    Parameters:
    word (str): The input string. Must only contain letters.
    
    Returns:
    list: A list of random pairs of adjacent letters from the word. If the word has fewer than 2 letters, returns a list of empty strings based on POSSIBLE_LETTERS length.
    
    Requirements:
    - random
    - string
    
    Raises:
    ValueError: If the input contains non-letter characters.
    
    Examples:
    >>> random.seed(0)
    >>> task_func('abcdef')
    ['de', 'de', 'ab']
    >>> task_func('xyz')
    ['yz', 'yz', 'yz']
    """

instruct prompt

Generates a list of random pairs of adjacent letters from the given word. The number of such pairs will be equal to the length of the constant POSSIBLE_LETTERS.
The function should raise the exception for: ValueError: If the input contains non-letter characters.
The function should output with:
    list: A list of random pairs of adjacent letters from the word. If the word has fewer than 2 letters, returns a list of empty strings based on POSSIBLE_LETTERS length.
You should write self-contained code starting with:

Code

import random
import string
POSSIBLE_LETTERS = ['a', 'b', 'c']
def task_func(word):

code prompt

Code

import random
import string
POSSIBLE_LETTERS = ['a', 'b', 'c']
def task_func(word):

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