benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf f52f831a-ba30-5672-b8d5-f80a8614d3a8

Problem

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

complete prompt

import random
import re


def task_func(text, seed=None):
    """
    Scramble the letters in each word of a given text, keeping the first and last letters of each word intact.

    Parameters:
    text (str): The text to be scrambled.
    seed (int, optional): A seed for the random number generator to ensure reproducible results.
                          Defaults to None (not set).

    Returns:
    str: The scrambled text.

    Requirements:
    - random
    - re

    Notes:
    - Words are determined by regex word boundaries.
    - The scrambling only affects words longer than three characters, leaving shorter words unchanged.

    Examples:
    >>> task_func('Hello, world!', 0)
    'Hello, wlrod!'
    >>> task_func("Programming is fun, isn't it?", 42)
    "Prmiangmrog is fun, isn't it?"
    """

instruct prompt

Scramble the letters in each word of a given text, keeping the first and last letters of each word intact.
Note that: Notes: Words are determined by regex word boundaries. The scrambling only affects words longer than three characters, leaving shorter words unchanged.
The function should output with:
    str: The scrambled text.
You should write self-contained code starting with:

Code

import random
import re
def task_func(text, seed=None):

code prompt

Code

import random
import re
def task_func(text, seed=None):

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