benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf f7ef6a54-8661-59c8-9f2d-16c12a46be90

Problem

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

complete prompt

import re
import string
import random


def task_func(text: str, seed=None) -> str:
    """
    Transforms a given string by removing special characters, normalizing whitespace,
    and randomizing character casing.

    Parameters:
    - text (str): The text string to be preprocessed.
    - seed (int, optional): Random seed for reproducibility. Defaults to None (not set).

    Returns:
    - str: The preprocessed text string.

    Requirements:
    - re
    - string
    - random

    Note:
    - This function considers special characters to be string punctuations.
    - Spaces, tabs, and newlines are replaced with with '_', '__', and '___' respectively.
    - To randomize casing, this function converts characters to uppercase with a 50% probability.

    Example:
    >>> task_func('Hello   World!', 0)
    'HeLlo___WORlD'
    >>> task_func('attention is all you need', 42)
    'ATtENTIOn_IS_ALL_You_Need'
    """

instruct prompt

Transforms a given string by removing special characters, normalizing whitespace, and randomizing character casing.
Note that: This function considers special characters to be string punctuations. Spaces, tabs, and newlines are replaced with with '_', '__', and '___' respectively. To randomize casing, this function converts characters to uppercase with a 50% probability.
The function should output with:
    str: The preprocessed text string.
You should write self-contained code starting with:

Code

import re
import string
import random
def task_func(text: str, seed=None) -> str:

code prompt

Code

import re
import string
import random
def task_func(text: str, seed=None) -> str:

entry point

task_func

libs

  • random
  • string
  • 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